:root {
  --bg: #ffffff;
  --text: #0b0f1a;
  --muted: rgba(11, 15, 26, 0.65);
  --border: rgba(11, 15, 26, 0.12);
  --card: #ffffff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.08);
  --primary: #004aad;
  --primary-ink: #ffffff;
  --ring: rgba(0, 74, 173, 0.28);
  --primary-soft: rgba(0, 74, 173, 0.08);
  --primary-line: rgba(0, 74, 173, 0.18);
  --navy: #0b0f1a;
  --blue: #004aad;
  --blue-soft: rgba(0, 74, 173, 0.08);
  --blue-line: rgba(0, 74, 173, 0.18);
  --ink: #0b0f1a;
  --line: rgba(11, 15, 26, 0.12);
  --surface: #ffffff;
  --green: #0f9d58;
  --green-soft: #e7f6ee;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #d92d20;
  --red-soft: #fdeceb;
  --radius: 18px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
svg { width: 16px; height: 16px; flex: none; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: Poppins, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 700px at 85% 20%, rgba(0, 74, 173, 0.12), transparent 60%),
    radial-gradient(900px 500px at 10% 10%, rgba(0, 0, 0, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }

.wordmark { font-weight: 400; letter-spacing: -0.6px; color: #000; }
.wordmark b { font-weight: 900; color: var(--primary); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--primary-soft); border: 1px solid var(--primary-line);
  color: rgba(0, 0, 0, 0.82); font-weight: 500; font-size: 12.5px;
}
.pill .dot {
  width: 8px; height: 8px; border-radius: 999px; background: var(--primary);
  box-shadow: 0 0 0 5px rgba(0, 74, 173, 0.14);
}

.booting { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- login ---------- */

.login {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.login__brand {
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login__logo { font-size: 26px; }
.login__mark { display: none; }

.login__pitch h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.12;
  margin: 18px 0 14px;
  letter-spacing: -1px;
  font-weight: 700;
}
.login__pitch p { color: var(--muted); font-size: 15px; max-width: 440px; margin: 0 0 28px; line-height: 1.65; }

.login__points { display: grid; gap: 12px; }
.login__point { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: rgba(11, 15, 26, 0.78); }
.login__point span:first-child {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

.login__cities { display: flex; gap: 8px; flex-wrap: wrap; }
.login__city {
  border: 1px solid var(--primary-line);
  background: var(--primary-soft);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 500;
}

.login__panel { display: grid; place-items: center; padding: 40px; }
.login__card {
  width: 100%; max-width: 400px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  padding: 28px;
}
.login__card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.4px; font-weight: 700; }
.login__card > p { margin: 0 0 22px; color: var(--muted); }

.login__hint {
  margin-top: 18px; padding: 12px 14px; border-radius: 12px;
  background: var(--primary-soft); border: 1px solid var(--primary-line);
  font-size: 12.5px; color: rgba(11, 15, 26, 0.72); line-height: 1.7;
}
.login__hint b { color: var(--text); }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  color: var(--text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
}

.sidebar__logo { display: flex; align-items: center; gap: 10px; font-size: 18px; padding: 4px 8px; }
.sidebar__mark { display: none; }
.sidebar__logo small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0.2px; margin-top: 1px; }

.nav { display: grid; gap: 3px; }
.nav__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); padding: 12px 10px 5px; font-weight: 600; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 12px;
  background: none; border: 0; width: 100%; text-align: left;
  color: rgba(11, 15, 26, 0.72); cursor: pointer; font-size: 13.5px; font-weight: 500;
}
.nav__item:hover { background: var(--primary-soft); color: var(--text); }
.nav__item.is-active { background: var(--primary); color: #fff; }
.nav__item svg { width: 17px; height: 17px; flex: none; }

.sidebar__foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
}
.sidebar__user div { min-width: 0; }
.sidebar__user strong { display: block; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user span { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -0.4px; font-weight: 700; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar__actions { display: flex; gap: 10px; align-items: center; }

.page { padding: 26px 28px 60px; display: grid; gap: 20px; }

/* ---------- primitives ---------- */

.card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card__head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card__head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.card__body { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: #003d91; }
.btn--ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: #f7f9fd; }
.btn--subtle { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.btn--subtle:hover { background: rgba(0, 74, 173, 0.14); }
.btn--danger { background: var(--red-soft); color: var(--red); border-color: #f7ccc8; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field { display: grid; gap: 6px; margin-bottom: 15px; }
.field label { font-size: 12.5px; font-weight: 500; color: rgba(11, 15, 26, 0.72); }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #fff; outline: none; width: 100%;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring);
}
.field small { color: var(--muted); font-size: 11.5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.section-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--muted); margin: 4px 0 14px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: #eef1f6; color: #475569;
}
.chip--draft { background: var(--amber-soft); color: var(--amber); }
.chip--finalised { background: var(--green-soft); color: var(--green); }
.chip--cancelled { background: var(--red-soft); color: var(--red); }
.chip--city { background: var(--primary-soft); color: var(--primary); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(0, 74, 173, 0.03); }
.table .co { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}
.stat__label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; font-weight: 500; }
.stat__value { font-size: 27px; font-weight: 700; margin-top: 8px; letter-spacing: -0.6px; }
.stat__foot { font-size: 12px; color: var(--muted); margin-top: 4px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; outline: none; }
.toolbar input { min-width: 230px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }

.empty { padding: 52px 24px; text-align: center; color: var(--muted); }
.empty h4 { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.empty p { margin: 0 auto 18px; max-width: 380px; line-height: 1.6; }

.city-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.city-tab {
  border: 1px solid var(--border); background: #fff; border-radius: 14px;
  padding: 12px 16px; cursor: pointer; text-align: left; min-width: 152px;
}
.city-tab strong { display: block; font-size: 14px; }
.city-tab span { font-size: 11.5px; color: var(--muted); }
.city-tab:hover { border-color: var(--primary-line); }
.city-tab.is-active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--ring); }

.premises-bar {
  display: flex; gap: 12px; align-items: center;
  background: var(--primary-soft); border: 1px solid var(--primary-line);
  border-radius: var(--radius); padding: 14px 16px; font-size: 13px; color: rgba(11, 15, 26, 0.78);
}
.premises-bar strong { color: var(--text); }

.doc-stack { display: grid; gap: 12px; }
.doc-type { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.doc-card__icon { width: 36px; height: 36px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.doc-stack .card__head { border-bottom: 0; }
.doc-stack .card:has(.card__body) .card__head { border-bottom: 1px solid var(--border); }
.card__body--files { padding: 8px 12px 12px; display: grid; gap: 2px; }

.file-row { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 12px; }
.file-row:hover { background: #f7f9fd; }
.file-row__ext {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700; background: #eef1f6; color: #5b6a82;
}
.file-row__ext.is-pdf { background: var(--red-soft); color: var(--red); }
.file-row__ext.is-doc { background: var(--primary-soft); color: var(--primary); }
.file-row__ext.is-img { background: var(--green-soft); color: var(--green); }
.file-row__meta { min-width: 0; flex: 1; }
.file-row__meta strong { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row__meta span { font-size: 11.5px; color: var(--muted); }
.file-row__actions { display: flex; gap: 6px; }
.doc-empty { padding: 20px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }

.overlay {
  position: fixed; inset: 0; background: rgba(11, 15, 26, 0.4);
  backdrop-filter: blur(2px); z-index: 60;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 40px 20px; overflow-y: auto;
}
.overlay--right { justify-content: flex-end; align-items: stretch; padding: 0; }

.modal {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  width: 100%; max-width: 860px;
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
}
.modal--sm { max-width: 460px; }
.modal__head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex: none; }
.modal__head h3 { margin: 0; font-size: 16px; }
.modal__head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.modal__body { padding: 22px; overflow-y: auto; flex: 1; }
.modal__foot { padding: 15px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex: none; }

.drawer { background: #fff; width: min(760px, 100%); height: 100vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.drawer--doc { width: min(920px, 100%); }
.drawer__head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.drawer__body { flex: 1; overflow: auto; background: #f4f7fb; padding: 20px; }
.drawer__body--doc { background: #d5deea; padding: 28px 20px 40px; }
.drawer__foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.a4-stack { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.a4-page {
  box-sizing: border-box;
  width: 210mm; height: 297mm; background: #fff;
  box-shadow: 0 14px 40px rgba(11, 15, 26, 0.14);
  display: flex; flex-direction: column;
  padding: 16mm 18mm 12mm;
  font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.7; color: var(--text);
  position: relative; overflow: hidden;
}
.a4-page__head {
  box-sizing: border-box; height: 38mm; min-height: 38mm; max-height: 38mm;
  flex: none; overflow: auto; padding-bottom: 8px; border-bottom: 1px dashed var(--primary-line);
}
.a4-page__body { flex: 1; min-height: 0; overflow: hidden; padding: 10px 0; }
.a4-page__foot {
  position: relative;
  box-sizing: border-box; height: 32mm; min-height: 32mm; max-height: 32mm;
  flex: none; overflow: visible; padding-top: 8px; border-top: 1px dashed var(--primary-line);
}
.a4-page__foot { color: var(--text); }

.icon-btn { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: #f2f5fa; color: var(--text); }

.viewer { width: 100%; height: 100%; min-height: 70vh; border: 0; border-radius: 12px; background: #fff; }
.viewer-img { max-width: 100%; display: block; margin: 0 auto; border-radius: 12px; box-shadow: var(--shadow-soft); }

.paper { background: #fff; padding: 44px 52px; border-radius: 14px; box-shadow: var(--shadow-soft); font-size: 13px; line-height: 1.7; font-family: Arial, Helvetica, sans-serif; }
.paper h2 { text-align: center; font-size: 16px; margin: 0 0 4px; color: var(--primary); }
.paper .paper__sub { text-align: center; color: var(--muted); font-size: 12px; font-style: italic; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--primary); }
.paper h4 { margin: 18px 0 7px; font-size: 13px; }
.paper p { margin: 0 0 11px; text-align: left; }
.paper table { width: 100%; border-collapse: collapse; margin: 6px 0 16px; font-size: 12.5px; }
.paper td { border: 1px solid var(--border); padding: 6px 9px; }
.paper td:first-child { width: 36%; font-weight: 600; background: #fafbfd; }
.paper ul, .paper ol { margin: 0 0 12px; padding-left: 20px; }
.paper li { margin-bottom: 5px; text-align: justify; }
.paper .sign-grid { display: flex; gap: 40px; margin: 26px 0 10px; }
.paper .sign-col { flex: 1; }
.paper .sign-col b { display: block; margin-bottom: 42px; }
.paper .sign-line { border-top: 1px solid #555; padding-top: 5px; font-size: 12.5px; }
.paper__header {
  border-bottom: 1px solid var(--primary-line); margin: 0 0 16px; padding-bottom: 10px;
}
.paper__footer {
  border-top: 1px solid var(--primary-line); margin: 22px 0 0; padding-top: 10px;
}

.bo-select { position: relative; min-width: 160px; }
.bo-select--compact { min-width: 72px; }
.bo-select.is-open { z-index: 30; }
.bo-select__btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #fff; cursor: pointer; text-align: left; color: var(--text);
}
.bo-select--compact .bo-select__btn { padding: 6px 8px; border-radius: 8px; }
.bo-select.is-open .bo-select__btn, .bo-select__btn:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); outline: none;
}
.bo-select__label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bo-select__chev { width: 16px; height: 16px; color: var(--primary); transition: transform 0.15s; }
.bo-select.is-open .bo-select__chev { transform: rotate(180deg); }
.bo-select__menu {
  display: none; position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--primary-line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; max-height: 260px; overflow: auto;
}
.bo-select.is-open .bo-select__menu { display: grid; gap: 2px; }
.bo-select__opt {
  border: 0; background: transparent; text-align: left; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; color: var(--text);
}
.bo-select__opt:hover { background: var(--primary-soft); color: var(--primary); }
.bo-select__opt.is-active { background: var(--primary); color: #fff; }
.toolbar .bo-select { min-width: 170px; }
.field .bo-select { width: 100%; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; max-width: 340px; }
.toast--error { background: var(--red); }
.toast--success { background: var(--green); }

.token {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary);
  padding: 2px 8px; border-radius: 8px;
}

.alert { padding: 11px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 16px; }
.alert--error { background: var(--red-soft); color: #97231a; border: 1px solid #f7ccc8; }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 16px; overflow-x: auto; padding: 12px 16px; }
  .sidebar__foot { margin: 0; border: 0; padding: 0; }
  .nav { grid-auto-flow: column; }
  .nav__label { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login__brand { display: none; }
}

@media (max-width: 680px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .paper { padding: 24px; }
}
