/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #dde1e7;
  --text:      #1a1d23;
  --muted:     #6b7280;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --warn:      #d97706;
  --success:   #16a34a;
  --radius:    6px;
  --shadow:    0 1px 3px rgba(0,0,0,.1);
}

body { font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-wrap { display: flex; min-height: 100vh; }

nav.sidebar {
  width: 220px; flex-shrink: 0;
  background: #1e293b; color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 1.5rem 0;
}
nav.sidebar .brand { font-size: 1.1rem; font-weight: 700; color: #fff; padding: 0 1.25rem 1.5rem; }
nav.sidebar a { display: block; padding: .55rem 1.25rem; color: #94a3b8; font-size: .9rem; }
nav.sidebar a:hover, nav.sidebar a.active { background: #334155; color: #fff; text-decoration: none; }
nav.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: #475569; padding: .75rem 1.25rem .25rem; }

.main { flex: 1; padding: 1.5rem; overflow-x: hidden; }
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; }
.card + .card { margin-top: 1rem; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; text-align: center; }
.summary-card .count { font-size: 2rem; font-weight: 700; line-height: 1; }
.summary-card .label { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.summary-card.warn .count { color: var(--warn); }
.summary-card.danger .count { color: var(--danger); }
.summary-card.primary .count { color: var(--primary); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: .6rem .75rem; border-bottom: 2px solid var(--border);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-new      { background: #dbeafe; color: #1d4ed8; }
.badge-review   { background: #fef3c7; color: #92400e; }
.badge-reviewed { background: #dcfce7; color: #166534; }
.badge-resub    { background: #fee2e2; color: #991b1b; }
.badge-dup      { background: #fce7f3; color: #9d174d; }

/* ── Filter chips ─────────────────────────────────────────────────────────── */
.filter-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip { padding: .3rem .85rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: .82rem; cursor: pointer; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=search],
select, textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .95rem; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-row { margin-bottom: 1rem; }
.form-inline { display: flex; gap: .5rem; align-items: flex-end; }
.form-inline > * { flex: 1; }
.form-inline button { flex: 0 0 auto; }

button, .btn {
  display: inline-block; padding: .5rem 1.1rem; border-radius: var(--radius);
  border: none; background: var(--primary); color: #fff; font-size: .9rem;
  font-weight: 600; cursor: pointer; text-align: center;
}
button:hover, .btn:hover { background: var(--primary-h); text-decoration: none; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: .65rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warn  { background: #fef3c7; color: #92400e; }
.alert-ok    { background: #dcfce7; color: #166534; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 1.5rem; }
.login-card label { margin-top: .75rem; }
.login-card button { width: 100%; margin-top: 1.25rem; padding: .65rem; }

/* ── Timeline ─────────────────────────────────────────────────────────────── */
.timeline { list-style: none; }
.timeline-item { border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: .75rem; }
.timeline-header { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem;
  cursor: pointer; flex-wrap: wrap; }
.timeline-header .subject { font-weight: 600; flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.timeline-header .meta { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.timeline-body { padding: .75rem 1rem; border-top: 1px solid var(--border); display: none; }
.timeline-body.open { display: block; }
.body-text { font-size: .85rem; white-space: pre-wrap; background: var(--bg);
  padding: .75rem; border-radius: var(--radius); max-height: 300px; overflow-y: auto; }
.attachment-list { list-style: none; margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.attachment-list li a { font-size: .82rem; }

/* ── Search ───────────────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.search-bar input { flex: 1; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  nav.sidebar { display: none; }
  .main { padding: 1rem; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  th, td { padding: .5rem; }
}
