:root {
  --bg:      #0b0b0e;
  --bg2:     #121217;
  --bg3:     #19191f;
  --border:  #252530;
  --text:    #e6e6f0;
  --text2:   #6868a0;
  --accent:  #4f9ef8;
  --green:   #3ecf8e;
  --red:     #e53e3e;
  --orange:  #f5a623;
  --sidebar-w: 225px;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* Loading */
#loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; gap: 16px; color: var(--text2); font-size: 13px; }
.spinner { width: 26px; height: 26px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner-sm { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar */
aside#sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-header { padding: 20px 14px 12px; border-bottom: 1px solid var(--border); }
.logo { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 1px; display: block; margin-bottom: 12px; }
#company-selector { display: flex; gap: 6px; align-items: center; }
#company-select { flex: 1; min-width: 0; background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 6px 8px; font-size: 12px; cursor: pointer; }
#company-select:focus { outline: none; border-color: var(--accent); }

nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; padding: 8px 10px; border-radius: var(--radius); color: var(--text2); text-decoration: none; font-size: 13px; transition: background 0.15s, color 0.15s; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }

.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#regime-badge { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text2); }

/* Main */
main#main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.view { display: block; padding: 28px 32px; overflow-y: auto; height: 100%; }
.view.hidden { display: none !important; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
h1 { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--text); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text2); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }
.stat-ok     { border-left: 3px solid var(--green); }
.stat-warn   { border-left: 3px solid var(--orange); }
.stat-bad    { border-left: 3px solid var(--red); }

/* Deadline items */
.deadline-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.deadline-item:hover { border-color: var(--accent); }
.deadline-name { flex: 1; font-size: 13px; font-weight: 500; }
.deadline-period { font-size: 12px; color: var(--text2); min-width: 80px; text-align: right; }
.deadline-due { font-size: 12px; min-width: 100px; text-align: right; }
.deadline-actions { display: flex; gap: 6px; }

/* Status badges */
.badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px; min-width: 72px; text-align: center; }
.badge-pending  { background: rgba(79,158,248,0.1);  color: var(--accent); }
.badge-filed    { background: rgba(62,207,142,0.1);  color: var(--green); }
.badge-overdue  { background: rgba(229,62,62,0.15);  color: var(--red); }
.badge-exempt   { background: rgba(104,104,160,0.1); color: var(--text2); }

/* Month nav */
.month-nav { display: flex; align-items: center; gap: 10px; }

/* Documents */
.upload-btn { cursor: pointer; }
.upload-progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text2); padding: 12px 0; }
.doc-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.doc-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.doc-name { font-size: 13px; font-weight: 500; flex: 1; }
.doc-summary { font-size: 12px; color: var(--text2); line-height: 1.5; }
.doc-meta { font-size: 11px; color: var(--text2); margin-top: 6px; }
.doc-actions { margin-top: 8px; display: flex; gap: 6px; }
.doc-type-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; background: rgba(79,158,248,0.1); color: var(--accent); }

/* Agent chat */
#view-agent { padding: 0; overflow: hidden; }
.agent-layout { display: flex; height: 100%; }
.chat-sidebar { width: 220px; min-width: 220px; border-right: 1px solid var(--border); padding: 16px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-list-item { padding: 8px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px; color: var(--text2); border: 1px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.15s; }
.chat-list-item:hover { background: var(--bg3); color: var(--text); }
.chat-list-item.active { background: var(--bg3); border-color: var(--accent); color: var(--text); }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; text-align: center; }
.welcome-icon { font-size: 40px; margin-bottom: 16px; color: var(--accent); }
.chat-welcome h2 { font-size: 18px; margin-bottom: 8px; }
.chat-welcome p { color: var(--text2); font-size: 13px; margin-bottom: 24px; }
.welcome-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; }
.suggestion { background: var(--bg2); border: 1px solid var(--border); color: var(--text2); border-radius: 20px; padding: 7px 14px; font-size: 12px; cursor: pointer; font-family: inherit; transition: border-color 0.15s, color 0.15s; }
.suggestion:hover { border-color: var(--accent); color: var(--text); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.chat-msg { display: flex; gap: 12px; max-width: 820px; }
.chat-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; font-weight: 700; }
.chat-msg.user .msg-avatar { background: var(--accent); color: #fff; }
.chat-msg.assistant .msg-avatar { background: var(--bg3); border: 1px solid var(--border); color: var(--accent); }
.msg-content { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; line-height: 1.7; max-width: 100%; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user .msg-content { background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 12px 2px 12px 12px; }
.chat-msg.assistant .msg-content { border-radius: 2px 12px 12px 12px; }
.msg-thinking { display: flex; align-items: center; gap: 8px; color: var(--text2); font-size: 12px; }
.dots span { animation: blink 1.4s infinite; display: inline-block; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.chat-input-area { border-top: 1px solid var(--border); padding: 14px 24px; display: flex; gap: 10px; align-items: flex-end; }
#chat-input { flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 10px 14px; font-size: 13px; font-family: inherit; resize: none; max-height: 120px; overflow-y: auto; line-height: 1.5; }
#chat-input:focus { outline: none; border-color: var(--accent); }
.btn-send { width: 36px; height: 36px; background: var(--accent); color: #fff; border: none; border-radius: 50%; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.btn-send:hover:not(:disabled) { background: #6bb3ff; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Forms & buttons */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
input, select, textarea { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 8px 12px; font-size: 13px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

button, .btn-ghost, .btn-secondary, .btn-primary-sm, .btn-primary-modal { cursor: pointer; border: none; border-radius: var(--radius); font-size: 13px; font-family: inherit; font-weight: 500; padding: 8px 14px; transition: background 0.15s; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text2); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-primary-sm { background: var(--accent); color: #fff; width: 100%; text-align: center; }
.btn-primary-sm:hover:not(:disabled) { background: #6bb3ff; }
.btn-primary-modal { background: var(--accent); color: #fff; }
.btn-primary-modal:hover:not(:disabled) { background: #6bb3ff; }
.btn-icon { background: var(--bg3); border: 1px solid var(--border); color: var(--text2); border-radius: var(--radius); width: 26px; height: 26px; padding: 0; font-size: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-icon:hover { color: var(--text); border-color: var(--text2); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

.filter-row { display: flex; gap: 10px; margin-bottom: 18px; }
.filter-row select { width: auto; flex: 1; }
.pagination { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; font-size: 13px; color: var(--text2); }
.empty-state { color: var(--text2); font-size: 13px; text-align: center; padding: 36px 0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 420px; }
.modal-box h2 { margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { width: auto; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: var(--radius); font-size: 13px; z-index: 200; opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

.hidden { display: none !important; }
