/* BNZ Portal — shared styles */
:root {
  --primary: #1a3c5e;
  --primary-light: #2a5a8e;
  --accent: #c8a84b;
  --danger: #c0392b;
  --success: #27ae60;
  --warning: #f39c12;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #2d3748;
  --text-muted: #718096;
  --sidebar-w: 240px;
  --header-h: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }
button { cursor: pointer; font-family: inherit; }

/* --- LAYOUT --- */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: var(--sidebar-w); background: var(--primary); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#header { height: var(--header-h); background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0; }
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* --- SIDEBAR --- */
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.5px; color: var(--accent); }
.sidebar-logo p { font-size: 11px; opacity: 0.7; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: rgba(255,255,255,0.75); cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: var(--accent); }
.nav-item .icon { width: 18px; text-align: center; }
.sidebar-bottom { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { font-size: 12px; opacity: 0.8; margin-bottom: 8px; }
.user-role { display: inline-block; background: var(--accent); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 3px; }

/* --- HEADER --- */
.header-title { font-size: 16px; font-weight: 600; flex: 1; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.badge { background: var(--danger); color: #fff; font-size: 10px; padding: 2px 5px; border-radius: 10px; min-width: 18px; text-align: center; }

/* --- CARDS & PANELS --- */
.panel { display: none; }
.panel.active { display: block; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* --- TABLES --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { font-weight: 600; color: var(--text-muted); background: #f8fafc; }
tr:hover td { background: #f8fafc; }
.table-link { color: var(--primary); cursor: pointer; font-weight: 500; }
.table-link:hover { text-decoration: underline; }

/* --- STATUS BADGES --- */
.status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.status-Active { background: #d4edda; color: #155724; }
.status-Closed, .status-Settled { background: #d1ecf1; color: #0c5460; }
.status-Archived { background: #e2e3e5; color: #383d41; }
.status-Draft { background: #fff3cd; color: #856404; }
.status-Issued { background: #cce5ff; color: #004085; }
.status-Overdue { background: #f8d7da; color: #721c24; }
.status-Done { background: #d4edda; color: #155724; }
.status-Pending { background: #fff3cd; color: #856404; }
.status-In-Progress { background: #cce5ff; color: #004085; }

/* --- FORMS --- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--text); transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* --- BUTTONS --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; border: none; transition: all 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b8943b; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; padding: 6px; }
.btn-ghost:hover { color: var(--text); }

/* --- MODALS --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.open { display: flex; }
.modal { background: var(--card); border-radius: 10px; padding: 28px; width: 560px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { font-size: 20px; cursor: pointer; color: var(--text-muted); background: none; border: none; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* --- AI CHAT --- */
.chat-container { display: flex; flex-direction: column; height: 600px; max-height: calc(100vh - 200px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 80%; padding: 12px 16px; border-radius: 12px; line-height: 1.5; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-radius: 12px 12px 4px 12px; }
.chat-msg.assistant { align-self: flex-start; background: #f0f4f8; color: var(--text); border-radius: 12px 12px 12px 4px; white-space: pre-wrap; }
.chat-input-row { display: flex; gap: 8px; padding: 12px 0 0; border-top: 1px solid var(--border); }
.chat-input-row textarea { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; resize: none; font-family: inherit; font-size: 14px; }
.chat-threads { border-right: 1px solid var(--border); width: 200px; overflow-y: auto; padding: 8px; }
.thread-item { padding: 8px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text-muted); }
.thread-item:hover, .thread-item.active { background: #f0f4f8; color: var(--text); }

/* --- TIMELINE --- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl-entry { position: relative; margin-bottom: 16px; }
.tl-dot { position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); }
.tl-entry.Note .tl-dot { background: var(--primary); }
.tl-entry.Hearing .tl-dot { background: var(--accent); }
.tl-entry.Filing .tl-dot { background: var(--success); }
.tl-entry.System .tl-dot { background: var(--text-muted); }
.tl-body { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 12px; }
.tl-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.tl-type { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: #f0f4f8; margin-right: 6px; }
.tl-text { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }

/* --- MISC --- */
.empty { text-align: center; padding: 40px; color: var(--text-muted); }
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fde8e8; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); }
.tag { display: inline-block; background: #edf2f7; color: var(--text-muted); font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; flex: 1; max-width: 320px; }
.search-bar input { border: none; outline: none; background: none; width: 100%; font-size: 13px; }
.filter-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; font-size: 13px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--card); cursor: pointer; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  #sidebar { display: none; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal { width: 95vw; }
}
