:root {
  --brand: #00a4bb;
  --action: #007a8a;
  --action-hover: #00687a;
  --accent: #ffba00;
  --text: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --danger: #b42318;
  --ok-bg: #e6f6f8;
  --warn-bg: #fff7e0;
  --r-card: 16px;
  --r-btn: 12px;
  --r-field: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Assistant", "Heebo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
h1, h2 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 16px; color: var(--muted); }
bdi { unicode-bidi: isolate; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: 0.9rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--card); border-block-end: 1px solid var(--line);
  min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.account { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 0.9rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 960px; margin: 0 auto; padding: 16px; outline: none; }
.card {
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 24px;
}
.center { max-width: 480px; margin: 32px auto; text-align: center; }

.btn {
  font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px;
  border-radius: var(--r-btn); border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; transition: background-color 150ms ease-out, transform 100ms ease-out;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .tab:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}
.btn.primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn.primary:hover { background: var(--action-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line); }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: 0.95rem; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-block-end: 12px;
}
.mailbox { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.mailbox .label { font-weight: 600; }
.actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; border-block-end: 1px solid var(--line); margin-block-end: 12px; overflow-x: auto; }
.tab {
  font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0;
  border-block-end: 3px solid transparent; padding: 10px 12px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--text); border-block-end-color: var(--brand); }

.section-title { margin-block: 16px 8px; }
.docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.doc {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 16px;
}
.doc-main { min-width: 0; flex: 1 1 280px; }
.doc-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.type { font-weight: 700; }
.subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 0.9rem; }
.chip { font-size: 0.85rem; padding: 2px 10px; border-radius: 999px; background: var(--line); color: var(--text); }
.chip.pending { background: var(--warn-bg); }
.chip.auto, .chip.approved { background: var(--ok-bg); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
select {
  font: inherit; min-height: 44px; padding: 6px 10px; border-radius: var(--r-field);
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.empty { text-align: center; padding: 24px; }

.skeleton { display: grid; gap: 8px; }
.skeleton div { height: 72px; border-radius: var(--r-card); background: linear-gradient(90deg, var(--line), #f1f5f9, var(--line)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

dialog { border: 0; border-radius: var(--r-card); padding: 24px; max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 23, 42, 0.4); }
.check { display: flex; gap: 8px; align-items: center; margin-block: 8px 16px; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed; inset-block-end: 16px; inset-inline: 16px; margin: 0 auto; max-width: 480px;
  background: var(--text); color: #fff; padding: 12px 16px; border-radius: var(--r-btn); text-align: center;
}
.toast.error { background: var(--danger); }

body.panel .top { display: none; }
body.panel main { padding: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media (max-width: 480px) {
  .who { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .actions .btn { flex: 1; }
}
