:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #0f1419;
  --bg-card: #141b24;
  --bg-input: #0d1117;
  --border: #1e2a3a;
  --border-light: #263347;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #a78bfa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Login Screen ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 16px;
  color: white;
}

.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-select, .login-form input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-select:focus, .login-form input:focus {
  border-color: var(--accent);
}

.login-status {
  text-align: center;
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ── Buttons ── */
.btn-primary {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-ghost {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-approve {
  background: var(--green);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.btn-reject {
  background: var(--red);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-sm {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: white;
}

.app-title {
  font-weight: 700;
  font-size: 16px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
}

.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(37,99,235,0.15);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Navigation Tabs ── */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  justify-content: center;
  overflow-x: auto;
}

.nav-tab {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-tab.active { color: var(--text-primary); background: var(--accent); }

/* ── Status Bar ── */
.status-bar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  overflow-x: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 100px;
  flex: 1;
}

.status-count {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.status-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-completed .status-count { color: var(--green); }
.status-pending .status-count { color: var(--yellow); }
.status-rejected .status-count { color: var(--red); }
.status-inprogress .status-count { color: var(--blue); }

/* ── Content Area ── */
.content-area {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px 24px;
}

.panel { display: none; padding: 16px 0; }
.panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 700;
}

/* ── Chat Panel ── */
.chat-container {
  display: flex;
  gap: 16px;
  height: 500px;
}

.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-thread-label {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  margin-top: 4px;
}

.chat-thread-label code {
  color: var(--text-secondary);
  font-size: 11px;
}

.sample-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.sample-button-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.capability-panel {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.capability-summary {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 10px;
}

.capability-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capability-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15,20,25,0.65);
  padding: 10px;
}

.capability-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.capability-meta {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.capability-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.sample-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.email-fields {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.email-fields input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  outline: none;
  resize: none;
  font-family: inherit;
  min-height: 40px;
  max-height: 120px;
}

.chat-input-area textarea:focus {
  border-color: var(--accent);
}

/* ── Chat Messages ── */
.msg {
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  max-width: 85%;
}

.msg.user {
  background: rgba(37,99,235,0.12);
  border: 1px solid rgba(37,99,235,0.25);
  margin-left: auto;
}

.msg.bot {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
}

.msg.sys {
  background: rgba(139,148,158,0.08);
  border: 1px solid rgba(139,148,158,0.2);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Inbox & Calendar Grids ── */
.inbox-grid, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.inbox-card, .calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.inbox-card-subject { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.inbox-card-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.inbox-card-body { font-size: 13px; color: var(--text-primary); margin-bottom: 10px; line-height: 1.4; }
.calendar-card-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.calendar-card-time { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.calendar-card-location { font-size: 12px; color: var(--text-muted); }

/* ── Approvals ── */
.approvals-grid {
  display: grid;
  gap: 12px;
}

.approval-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.approval-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.approval-card-id {
  font-size: 13px;
  color: var(--text-muted);
}

.approval-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.approval-field {
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}

.approval-field b {
  color: var(--text-secondary);
  text-transform: capitalize;
}

.approval-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.approval-actions input {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
}

.approval-editors {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.approval-input, .approval-editor {
  width: 100%;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
}

.approval-editor {
  min-height: 110px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
}

/* ── History ── */
.history-grid {
  display: grid;
  gap: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.history-row:hover {
  border-color: var(--accent);
  background: rgba(37,99,235,0.05);
}

.history-row.history-active {
  border-color: var(--accent);
  background: rgba(37,99,235,0.1);
}

.history-left { display: flex; flex-direction: column; gap: 4px; }
.history-template { font-weight: 600; font-size: 14px; text-transform: capitalize; }
.history-date { font-size: 12px; color: var(--text-muted); }

.status-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  text-transform: capitalize;
}

/* ── Audit ── */
.audit-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-height: 500px;
  overflow-y: auto;
  font-size: 13px;
}

.audit-section { margin-bottom: 16px; }

.audit-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.audit-kv-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.audit-key { color: var(--text-secondary); font-size: 12px; min-width: 120px; text-transform: capitalize; }
.audit-val { color: var(--text-primary); font-weight: 500; }

.audit-subheading {
  margin-top: 8px; margin-bottom: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
}

.audit-chip {
  font-size: 11px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px;
  border: 1px solid; text-transform: capitalize;
}

.audit-event-row {
  display: flex; align-items: baseline; gap: 6px;
  padding: 5px 0; border-bottom: 1px solid rgba(30,42,58,0.5); flex-wrap: wrap;
}

.audit-node-badge {
  font-size: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  color: var(--text-secondary); white-space: nowrap;
}

.audit-event-type { color: var(--blue); font-weight: 700; font-size: 11px; white-space: nowrap; }
.audit-event-msg { color: var(--text-primary); flex: 1; min-width: 0; }
.audit-time { color: var(--text-muted); font-size: 11px; white-space: nowrap; margin-left: auto; }

.audit-tool-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid rgba(30,42,58,0.5);
}

.audit-tool-icon { font-size: 13px; }
.audit-tool-name { color: var(--purple); font-weight: 600; flex: 1; }
.audit-tool-dur { font-size: 11px; color: var(--text-muted); }

.audit-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

/* ── Directory ── */
.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.directory-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.directory-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.directory-detail { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .chat-container { flex-direction: column; height: auto; }
  .chat-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .chat-main { height: 400px; }
  .status-bar { flex-wrap: wrap; }
  .nav-tabs { overflow-x: auto; }
  .inbox-grid, .calendar-grid { grid-template-columns: 1fr; }
}
