:root {
  --ink: #12161F;
  --ink-soft: #1B2130;
  --brass: #B08D57;
  --brass-soft: #E4D3B4;
  --bg: #F5F5F3;
  --panel: #FFFFFF;
  --border: #E4E3DF;
  --text: #1A1D23;
  --text-mute: #6B7280;
  --green: #1F7A4D;
  --red: #B3432B;
  --amber: #B08D57;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(18,22,31,0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--panel);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(176,141,87,0.15);
}
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 10px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-mark {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--brass);
  font-weight: 600;
  margin-bottom: 4px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 28px 0;
  color: var(--ink);
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--text-mute); margin-bottom: 6px; font-weight: 500; }
.field input { width: 100%; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn-primary { background: var(--ink); color: #fff; width: 100%; padding: 11px; }
.btn-primary:hover { background: var(--ink-soft); }
.btn-brass { background: var(--brass); color: #fff; }
.btn-brass:hover { background: #9c7a49; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 10px; }
.hint { color: var(--text-mute); font-size: 12px; margin-top: 18px; text-align: center; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}
.brand { padding: 0 10px 22px 10px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--brass-soft); margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: rgba(255,255,255,0.75); font-size: 13.5px; font-weight: 500;
  cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--brass); color: #fff; }
.nav-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.35); padding: 16px 12px 6px; }
.sidebar-footer { margin-top: auto; padding: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); background: rgba(255,255,255,0.05); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brass);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: capitalize; }
.logout-link { font-size: 12px; color: rgba(255,255,255,0.45); margin-top: 8px; display: block; cursor: pointer; padding: 0 10px; }
.logout-link:hover { color: #fff; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-input { width: 260px; }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-value { font-size: 24px; font-weight: 700; color: var(--ink); }
.stat-label { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.stat-card.alert .stat-value { color: var(--red); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel-title { font-size: 14px; font-weight: 700; margin: 0 0 14px 0; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
.filters-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-size: 11.5px; color: var(--text-mute); font-weight: 600;
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr { cursor: pointer; }
table.data-table tbody tr:hover { background: #FAF8F4; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill-new { background: #E8EEFB; color: #2A4E9E; }
.pill-progress { background: #FDF1DC; color: #935E00; }
.pill-won { background: #E4F3E9; color: var(--green); }
.pill-lost { background: #F7E6E2; color: var(--red); }
.pill-dup { background: #F1F1F1; color: #666; }
.source-tag { font-size: 11px; color: var(--text-mute); }
.name-cell { font-weight: 600; }
.mobile-cell { color: var(--text-mute); font-size: 12.5px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col { flex: 0 0 240px; background: #F0EFEB; border-radius: var(--radius); padding: 10px; max-height: 74vh; display: flex; flex-direction: column; }
.kanban-col-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; color: var(--text-mute); }
.kanban-cards { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kanban-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; cursor: pointer; font-size: 12.5px; }
.kanban-card:hover { border-color: var(--brass); }
.kanban-card-name { font-weight: 600; margin-bottom: 3px; }

/* ---------- Drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(18,22,31,0.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100vw; background: var(--panel); z-index: 41; box-shadow: -8px 0 30px rgba(0,0,0,0.15); display: flex; flex-direction: column; }
.drawer-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-close { cursor: pointer; color: var(--text-mute); font-size: 20px; line-height: 1; background: none; border: none; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 20px; }
.quick-actions .btn { width: 100%; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 18px; font-size: 13px; }
.detail-grid .k { color: var(--text-mute); font-size: 11.5px; }
.detail-grid .v { font-weight: 500; }
.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-mute); margin: 18px 0 10px; }
.timeline-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.timeline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brass); margin-top: 5px; flex-shrink: 0; }
.timeline-desc { color: var(--text-mute); font-size: 12px; }
.timeline-time { color: var(--text-mute); font-size: 11px; margin-top: 2px; }
select.status-select { width: 100%; font-weight: 600; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-mute); font-size: 13px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(18,22,31,0.4); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--panel); border-radius: 8px; padding: 22px; width: 380px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal h3 { margin: 0 0 16px 0; font-size: 15px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-size: 13px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

@media (max-width: 720px) {
  .sidebar { position: fixed; left: -220px; top: 0; bottom: 0; z-index: 45; transition: left 0.2s ease; }
  .sidebar.open { left: 0; }
  .content { padding: 14px; }
  .two-col { grid-template-columns: 1fr; }
  table.data-table { font-size: 12px; }
}
