/* AMMAR AGENCY TRACKER — Glass Premium (dark) */
:root {
  --bg: #070a17; --bg2: #0d1230;
  --glass: rgba(255,255,255,.045); --glass-2: rgba(255,255,255,.075); --glass-border: rgba(255,255,255,.10);
  --text: #e8ebf7; --muted: #8f97b8; --line: rgba(255,255,255,.08);
  --blue: #5b8cff; --purple: #9b6bff; --cyan: #36d1e0; --pink: #f472b6;
  --accent: #7c8cff; --grad: linear-gradient(135deg, #4f7cff 0%, #8b5cf6 100%);
  --good: #34d399; --bad: #fb7185; --warn: #fbbf24;
  --radius: 16px; --sidebar: 236px;
}
* { box-sizing: border-box; }
html { background: #0b0f26; }
html, body { min-height: 100%; }
body {
  margin: 0; color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(139,92,246,.22), transparent 60%),
    radial-gradient(800px 600px at -10% 20%, rgba(79,124,255,.20), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(54,209,224,.10), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
}
a { color: #a5b4ff; text-decoration: none; }
a:hover { color: #c7d0ff; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: rgba(0,0,0,.25); border: 1px solid var(--line); padding: 12px; border-radius: 10px; overflow-x: auto; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 12px; font-weight: 650; color: #d7dcf3; }
.muted { color: var(--muted); } .small { font-size: 12px; } .r { text-align: right; font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 20px 14px; background: rgba(8,11,28,.55); border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); }
.logo .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center;
  font-weight: 800; font-size: 15px; box-shadow: 0 6px 24px rgba(124,92,255,.45); color: #fff; }
.logo b { display: block; font-size: 13px; letter-spacing: .06em; line-height: 1.2; }
.logo small { color: var(--muted); font-size: 11px; }
.nav-group { margin: 14px 0 6px; padding: 0 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #6b7399; }
.sidebar .nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: #b9c0dc; margin: 1px 0; }
.sidebar a.nav:hover { background: var(--glass); color: #fff; }
.sidebar a.nav.on { background: linear-gradient(135deg, rgba(79,124,255,.28), rgba(139,92,246,.28)); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10); }
.sidebar .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .user { margin-top: 22px; padding: 12px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.content { flex: 1; min-width: 0; padding: 22px 28px 40px; }
.btn.menu-btn { display: none; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.head > div:last-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- glass ---------- */
.panel, .card, .filterbar {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.05);
}
.panel { padding: 18px; margin-bottom: 16px; }
.panel h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 > .panel, .grid3 > .panel { margin-bottom: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { padding: 15px 16px; color: var(--text); position: relative; overflow: hidden; display: block; }
a.card:hover { background: var(--glass-2); color: var(--text); }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); opacity: .7; }
.card .label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.card .value { font-size: 25px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.card .hint { font-size: 12px; color: var(--muted); }
.delta { font-size: 12.5px; font-weight: 600; }
.bar { height: 6px; background: rgba(255,255,255,.08); border-radius: 4px; margin-top: 9px; overflow: hidden; position: relative; }
.bar span { display: block; height: 100%; background: var(--grad); border-radius: 4px; }
.bar span.bad { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.bar i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; opacity: .55; }

.chart { position: relative; height: 290px; } .chart.sm { height: 210px; } .chart.lg { height: 360px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
table.sortable th { cursor: pointer; user-select: none; }
table.sortable th:hover { color: #fff; }
table.sortable th.asc::after { content: " ▲"; } table.sortable th.desc::after { content: " ▼"; }
tbody tr:hover { background: rgba(124,140,255,.06); }
td.r, th.r { text-align: right; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--glass-border);
  color: #c9cfee; background: rgba(255,255,255,.04); white-space: nowrap; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill.up { background: rgba(52,211,153,.14); color: var(--good); }
.pill.down { background: rgba(251,113,133,.14); color: var(--bad); }
.pill.flat { background: rgba(255,255,255,.07); color: var(--muted); }
.pill.warn { background: rgba(251,191,36,.14); color: var(--warn); }
.minibar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #f43f5e, #fb7185); min-width: 2px; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,.06); min-width: 120px; }
.stack span { display: block; height: 100%; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 7px; }
input, select, textarea {
  font: inherit; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid var(--glass-border);
  border-radius: 10px; padding: 8px 11px; min-width: 0;
}
select option { background: #121735; }
input[type=checkbox] { accent-color: var(--purple); }
input[type=date] { color-scheme: dark; }
textarea { width: 100%; min-height: 70px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(124,140,255,.6); outline-offset: -1px; }
.form { max-width: 720px; display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; background: var(--grad); color: #fff;
  border: 0; border-radius: 10px; padding: 8px 15px; cursor: pointer; box-shadow: 0 6px 20px rgba(110,90,255,.35); white-space: nowrap; }
.btn:hover { color: #fff; filter: brightness(1.1); }
.btn.ghost { background: var(--glass); border: 1px solid var(--glass-border); box-shadow: none; color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { background: linear-gradient(135deg, #e11d48, #fb7185); box-shadow: none; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: #fff; } button.link.danger { color: var(--bad); }
form.inline { display: inline; }

/* filter bar */
.filterbar { padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.seg { display: inline-flex; background: rgba(0,0,0,.25); border: 1px solid var(--glass-border); border-radius: 11px; padding: 3px; }
.seg a, .seg button { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 12.5px; background: none; border: 0; cursor: pointer; font-family: inherit; }
.seg a.on, .seg button.on { background: var(--grad); color: #fff; }
.filterbar input, .filterbar select { padding: 6px 9px; }
.filterbar .period { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }
.filterbar .period b { color: var(--text); font-size: 13px; display: block; }

.flash { padding: 11px 14px; border-radius: 12px; margin-bottom: 14px; border: 1px solid var(--glass-border); background: var(--glass); }
.flash.ok { border-color: rgba(52,211,153,.5); } .flash.error { border-color: rgba(251,113,133,.6); color: #fecdd3; }
.flash.warn { border-color: rgba(251,191,36,.5); }
.login { max-width: 380px; margin: 12vh auto; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.empty { text-align: center; padding: 50px 20px; }
.errors { color: #fecdd3; margin: 0; padding-left: 18px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.note { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: rgba(255,255,255,.02); }
details.note[open] { background: rgba(255,255,255,.04); }
details.note summary { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.report-preview { background: rgba(255,255,255,.96); color: #1e2235; border-radius: 12px; padding: 28px 34px; overflow-x: auto; min-width: 0; }
.report-preview h2 { color: #312e81; } .report-preview h3 { color: #3730a3; border-bottom: 1px solid #e3e6f3; padding-bottom: 4px; margin-top: 22px; }
.report-preview h4 { margin: 14px 0 4px; }
.report-preview table { font-size: 12.5px; margin: 8px 0 14px; }
.report-preview th { color: #4b5175; background: #eef0fb; } .report-preview td, .report-preview th { border-bottom: 1px solid #e3e6f3; }
.report-preview tbody tr:hover { background: none; }

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: fixed; z-index: 30; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .btn.menu-btn { display: inline-flex; margin-bottom: 12px; }
  .content { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .filterbar .period { margin-left: 0; text-align: left; }
}
@media print {
  .sidebar, .filterbar, .no-print, .menu-btn { display: none !important; }
  body { background: #fff; } .content { padding: 0; }
}

/* ---------- phase 2 additions ---------- */
.sidebar .nav.disabled { opacity: .45; cursor: not-allowed; }
.sidebar .nav .tag { margin-left: auto; font-size: 10px; padding: 0 6px; }
.note { font-size: 12px; color: var(--muted); border-left: 3px solid var(--warn); padding: 6px 10px; background: rgba(251,191,36,.06);
  border-radius: 0 8px 8px 0; margin: 0 0 14px; }
.note.info { border-left-color: var(--accent); background: rgba(124,140,255,.07); }
.unit { font-size: 10.5px; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; display: block; }
th a { color: inherit; } th a:hover { color: #fff; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--muted); }
.card.disabled { opacity: .6; } .card.disabled .value { font-size: 15px; color: var(--muted); }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.bar-cell .b { height: 8px; border-radius: 4px; }
.bar-cell .b.neg { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.bar-cell .b.pos { background: linear-gradient(90deg, #10b981, #34d399); }
.drop { border: 2px dashed var(--glass-border); border-radius: 14px; padding: 26px; text-align: center; }
.drop.hover { border-color: var(--accent); background: rgba(124,140,255,.06); }
.list-plain { margin: 0; padding-left: 18px; } .list-plain li { margin: 3px 0; }
.status-applied { color: var(--good); } .status-failed { color: var(--bad); } .status-preview { color: var(--warn); }
.status-superseded, .status-discarded { color: var(--muted); }
.days { display: flex; gap: 4px; flex-wrap: wrap; } .days span { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: rgba(255,255,255,.05); }
.days span.on { background: rgba(52,211,153,.18); color: var(--good); }
.report-preview .muted { color: #6b7194; } .report-preview .good { color: #047857; } .report-preview .bad { color: #be123c; }
.report-preview .note { color: #5b6080; background: #fff8e6; }
@media print { .report-preview { box-shadow: none; padding: 0; } .content > *:not(.report-preview):not(.flash) { display: none !important; } }

/* ---------- consistency & mobile (phase C) ---------- */
.grid2 > *, .grid3 > * { min-width: 0; }
.panel h3 { flex-wrap: wrap; }
.panel h3 .seg { font-weight: 500; }
.panel .row:last-child { margin-bottom: 0; }
.kv dd { overflow-wrap: anywhere; }
td, th { overflow-wrap: normal; }
@media (max-width: 900px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 12px; } .card .value { font-size: 19px; }
  .panel { padding: 14px; }
  .panel table:not(.tablewrap table) { display: block; overflow-x: auto; white-space: nowrap; }
  .head h1 { font-size: 19px; }
  .head > div:last-child { width: 100%; }
  .filterbar { gap: 8px; } .filterbar label { flex: 1 1 140px; }
  .report-preview { padding: 16px; }
  .report-preview table { display: block; overflow-x: auto; }
  .bar-cell { min-width: 110px; }
}
@media (max-width: 420px) { .cards { grid-template-columns: minmax(0, 1fr); } }
