:root { --primary-color: #0056b3; --secondary-color: #007BFF; --accent-color: #e3f2fd; --success-color: #28a745; --warning-color: #ffc107; --danger-color: #dc3545; --info-color: #17a2b8; --sidebar-width: 250px; --topbar-height: 60px; --bg-light: #f4f6f9; }
* { box-sizing: border-box; outline: none; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; background: var(--bg-light); color: #333; height: 100vh; overflow-x: hidden; }
.hidden { display: none !important; }

/* Auth Screens */
#loginScreen, #registerScreen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.auth-card { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 15px 30px rgba(0,0,0,0.2); width: 100%; max-width: 400px; }
.auth-logo { height: 70px; display: block; margin: 0 auto 25px; }
.auth-card h2 { text-align: center; color: var(--primary-color); margin-bottom: 30px; font-weight: 600; }

/* Sidebar Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: #2c3e50; color: #fff; position: fixed; height: 100vh; z-index: 1000; box-shadow: 3px 0 10px rgba(0,0,0,0.1); display: flex; flex-direction: column; }
.sidebar-header { padding: 25px 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.1); }
.sidebar-header img { height: 40px; margin-bottom: 10px; }
.sidebar-header h3 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.5px; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; flex-grow: 1; }
.sidebar-menu li a { display: flex; align-items: center; padding: 16px 25px; color: rgba(255,255,255,0.75); text-decoration: none; transition: all 0.3s; border-left: 4px solid transparent; font-weight: 500; font-size: 14px; }
.sidebar-menu li a i { width: 25px; margin-right: 15px; font-size: 16px; }
.sidebar-menu li a:hover { background: rgba(255,255,255,0.05); color: #fff; border-left-color: var(--secondary-color); }
.sidebar-menu li a.active { background: rgba(0, 123, 255, 0.2); color: #fff; border-left-color: var(--secondary-color); }

/* Main Content */
.main-content { margin-left: var(--sidebar-width); flex-grow: 1; background: var(--bg-light); min-height: 100vh; }
.topbar { height: var(--topbar-height); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.05); display: flex; justify-content: space-between; align-items: center; padding: 0 30px; position: sticky; top: 0; z-index: 999; }
.topbar h2 { margin: 0; font-size: 20px; color: #333; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 15px; }
.topbar-user span { font-weight: 500; color: #666; font-size: 14px; }
.btn-logout { background: var(--danger-color); color: white; padding: 6px 15px; font-size: 13px; border-radius: 4px; }
.btn-logout:hover { background: #c82333; }
.content-wrapper { padding: 30px; }

/* Cards */
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 25px; margin-bottom: 30px; }
.card { background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); border-left: 4px solid var(--secondary-color); transition: transform 0.2s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
.card h3 { margin: 0 0 5px; font-size: 28px; color: var(--primary-color); }
.card p { margin: 0; color: #666; font-weight: 500; }
.card.pending { border-left-color: var(--warning-color); }
.card.valid { border-left-color: var(--info-color); }
.card.paid { border-left-color: var(--success-color); }
.section-box { background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); margin-bottom: 30px; }
.section-box h4 { margin-top: 0; color: var(--primary-color); border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 20px; font-size: 16px; }

/* Forms & Inputs */
input, select { padding: 12px 15px; width: 100%; margin-bottom: 15px; border: 1px solid #e0e0e0; border-radius: 5px; font-size: 14px; transition: border 0.3s; }
input:focus, select:focus { border-color: var(--secondary-color); box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }
button { padding: 10px 20px; background: var(--secondary-color); color: white; border: none; cursor: pointer; border-radius: 5px; font-weight: 600; transition: 0.2s; font-size: 14px; }
button:hover { background: var(--primary-color); transform: translateY(-1px); }
.btn-success { background: var(--success-color); }
.btn-warning { background: var(--warning-color); color: #000; }
.btn-delete { background: var(--danger-color); color: white; padding: 5px 12px; font-size: 12px; border-radius: 3px; }
.btn-edit { background: var(--info-color); color: white; padding: 5px 12px; font-size: 12px; border-radius: 3px; }
.toggle-btn { background: #fff; color: var(--secondary-color); border: 1px solid var(--secondary-color); margin-bottom: 20px; }
.toggle-btn:hover { background: var(--accent-color); }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; }
th { background: var(--accent-color); color: var(--primary-color); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr:hover { background: #fafafa; }
.table-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.search-box { padding: 8px 15px; border: 1px solid #ddd; border-radius: 4px; width: 250px; }
.count-badge { background: var(--primary-color); color: white; padding: 6px 12px; border-radius: 15px; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.action-btns { display: flex; gap: 5px; }

/* Misc */
.error { color: #fff; background-color: var(--danger-color); padding: 15px; border-radius: 5px; margin-bottom: 20px; text-align: center; font-weight: bold; font-size: 14px; }
.company-selector { background: #f8f9fa; padding: 20px; border-radius: 8px; margin-bottom: 25px; border: 1px solid #e0e0e0; }
.searchable-dropdown { position: relative; width: 100%; }
.dropdown-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ccc; max-height: 200px; overflow-y: auto; z-index: 1000; display: none; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.dropdown-list div { padding: 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.dropdown-list div:hover { background: var(--accent-color); }

.selected-company-stats { display: none; margin-top: 20px; }
.stats-active { display: block; }
.mini-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.mini-card { background: #fff; padding: 15px; border-radius: 6px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid #eee; }
.mini-card h4 { margin: 0; font-size: 24px; }
.mini-card span { font-size: 11px; text-transform: uppercase; font-weight: bold; }
.mini-card.pending h4 { color: #856404; }
.mini-card.valid h4 { color: #0c5460; }
.mini-card.paid h4 { color: #155724; }

/* Chat Widget */
.chat-container { position: fixed; bottom: 20px; right: 20px; width: 320px; background: white; border-radius: 10px; box-shadow: 0 5px 25px rgba(0,0,0,0.15); z-index: 9999; border: 1px solid #ddd; }
.chat-header { background: var(--primary-color); color: white; padding: 12px 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; border-radius: 10px 10px 0 0; }
.chat-body { height: 250px; overflow-y: auto; padding: 15px; background: #f9f9f9; display: flex; flex-direction: column; }
.chat-msg { margin-bottom: 10px; max-width: 90%; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-msg.other { align-self: flex-start; }
.msg-bubble { padding: 8px 12px; border-radius: 15px; display: inline-block; font-size: 13px; line-height: 1.4; }
.chat-msg.mine .msg-bubble { background: var(--secondary-color); color: white; }
.chat-msg.other .msg-bubble { background: white; border: 1px solid #e0e0e0; }
.msg-info { font-size: 9px; color: #888; margin-top: 3px; padding: 0 4px; }
.chat-footer { padding: 10px; background: white; border-top: 1px solid #eee; display: flex; gap: 5px; border-radius: 0 0 10px 10px; }
.chat-footer input { flex: 1; padding: 8px; border-radius: 20px; border: 1px solid #ccc; margin-bottom: 0; font-size: 12px; }
.chat-footer button { width: 35px; height: 35px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.chat-hidden { display: none; }

@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar-header h3, .sidebar-menu li a span { display: none; }
    .main-content { margin-left: 70px; }
    .form-grid { grid-template-columns: 1fr; }
}