/* ==========================================================================
   Officials Management System — navy & gold minimal theme
   ========================================================================== */

:root {
  --navy-950: #061124;
  --navy-900: #0a1a33;
  --navy-800: #0e2244;
  --navy-700: #16305c;
  --navy-600: #1f3f74;
  --navy-500: #2c5590;

  --gold: #d4af37;
  --gold-deep: #b8912a;
  --gold-soft: #f6eccd;

  --ink: #182133;
  --muted: #6b7688;
  --line: #e4e8f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --danger: #c0392b;
  --success: #1e8e5a;
  --warn: #b7791f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(10, 26, 51, 0.08);
  --shadow-lg: 0 20px 50px rgba(10, 26, 51, 0.18);
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-600); text-decoration: none; }
a:hover { color: var(--gold-deep); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ---- App shell --------------------------------------------------------- */
.app-shell { min-height: 100vh; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 254px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #cdd6e6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 26px 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.18);
}

.brand .mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--navy-950);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.brand .brand-logo {
  width: 40px; height: 40px; object-fit: contain; display: block; flex: none;
}

.brand .name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.15; }
.brand .name span { display: block; font-size: 11px; color: var(--gold); font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; margin-top: 3px; }

.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav .group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px;
  color: #66748f; padding: 16px 12px 8px; font-weight: 700;
}
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 10px;
  color: #c3cddd; font-size: 14px; font-weight: 500;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active {
  background: rgba(212,175,55,.14);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}
.nav a.active .ico { color: var(--gold); opacity: 1; }

.sidebar .foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11.5px;
  color: #66748f;
}

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

.topbar {
  height: 66px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 17px; font-weight: 700; color: var(--navy-900); }
.topbar .title small { display:block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }

.user-chip { display: flex; align-items: center; gap: 12px; }
.user-chip .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--navy-800); color: var(--gold);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.user-chip .who { line-height: 1.2; }
.user-chip .who b { font-size: 13.5px; color: var(--navy-900); display: block; }
.user-chip .who span { font-size: 11.5px; color: var(--muted); }

.btn-ghost {
  background: transparent; border: 1px solid var(--line); color: var(--navy-700);
  padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { border-color: var(--navy-600); color: var(--navy-900); background: #f7f9fc; }

.content { padding: 26px; max-width: 1180px; width: 100%; margin: 0 auto; flex: 1; }

/* ---- Responsive shell (mobile sidebar) --------------------------------- */
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-btn { display: none; }
.side-close { display: none; }
.backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    height: 100vh; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: 0 20px 50px rgba(10,26,51,.35);
  }
  .sidebar.open { transform: translateX(0); }

  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0;
    border: 1px solid var(--line); background: #fff; color: var(--navy-800);
    border-radius: 10px; font-size: 18px; line-height: 1; cursor: pointer;
  }
  .menu-btn:hover { border-color: var(--navy-600); }

  .side-close {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto; width: 32px; height: 32px; flex-shrink: 0;
    border: none; border-radius: 8px; cursor: pointer;
    background: rgba(255,255,255,.08); color: #fff; font-size: 20px; line-height: 1;
  }
  .side-close:hover { background: rgba(255,255,255,.16); }

  .backdrop {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(6,17,36,.5); backdrop-filter: blur(2px);
  }
  .backdrop.show { display: block; }

  .topbar { padding: 0 16px; }
  .topbar .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 18px; }
}

@media (max-width: 640px) {
  .user-chip .who { display: none; }
  .topbar .title { font-size: 15px; }
  .content { padding: 14px; }
  .modal-body { padding: 18px; }
  .modal-overlay { padding: 24px 12px; }
}

body.nav-open { overflow: hidden; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: transform .05s, box-shadow .15s, background .15s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
  color: #fff; box-shadow: 0 6px 16px rgba(14,34,68,.28);
}
.btn-primary:hover { box-shadow: 0 10px 22px rgba(14,34,68,.34); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--navy-950); box-shadow: 0 6px 16px rgba(212,175,55,.32);
}
.btn-gold:hover { filter: brightness(1.04); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--navy-700); }
.btn-outline:hover { border-color: var(--navy-600); }
.btn-danger { background: #fff; border-color: #f0c9c3; color: var(--danger); }
.btn-danger:hover { background: #fdf3f1; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---- Cards / panels ---------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.card-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15.5px; color: var(--navy-900); }
.card-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 960px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
  border-radius: 50%; background: radial-gradient(circle, rgba(212,175,55,.16), transparent 70%);
}
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 30px; font-weight: 800; color: var(--navy-900); margin-top: 8px; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Forms ------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--navy-800);
  margin-bottom: 7px; letter-spacing: .2px;
}
.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 10px; font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(31,63,116,.12);
}
textarea.input { resize: vertical; min-height: 84px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row, .field-row-3 { grid-template-columns: 1fr; } }

/* ---- Tables ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 700; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfd; }
.cell-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Badges / chips ---------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .3px; text-transform: capitalize;
}
.badge.draft { background: #eef1f6; color: #566077; }
.badge.submitted { background: #fdf3d6; color: #946c0a; }
.badge.approved { background: #e3f5ec; color: var(--success); }
.badge.revision { background: #fdecea; color: var(--danger); }
.badge.open { background: #e3f5ec; color: var(--success); }
.badge.closed { background: #eef1f6; color: #566077; }
.badge.gold { background: var(--gold-soft); color: var(--gold-deep); }
.badge.navy { background: #e7edf7; color: var(--navy-700); }

.token-chip {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  background: var(--navy-950); color: var(--gold); padding: 5px 10px;
  border-radius: 7px; letter-spacing: .5px;
}

/* ---- Empty / loading --------------------------------------------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 10px; opacity: .5; }
.empty h4 { color: var(--navy-800); margin-bottom: 6px; font-size: 15px; }
.empty p { font-size: 13px; margin: 0 auto; max-width: 340px; }

.loading { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--muted); gap: 12px; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--gold);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Auth / login ------------------------------------------------------ */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr 0.95fr;
}

.auth-side {
  background:
    radial-gradient(circle at 20% 15%, rgba(212,175,55,.18), transparent 45%),
    linear-gradient(160deg, var(--navy-800), var(--navy-950));
  color: #e7edf7; padding: 60px 56px; display: flex; flex-direction: column; justify-content: space-between; text-align: left;
}
.auth-side > .small { margin-top: 26px; }
.auth-side .mark-lg {
  width: 54px; height: 54px; border-radius: 15px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--navy-950); display: grid; place-items: center; font-weight: 800; font-size: 20px;
}

.auth-side .auth-logo { width: 76px; height: 76px; object-fit: contain; display: block; }
.auth-side h1 { color: #fff; font-size: 30px; margin-top: 34px; line-height: 1.2; }
.auth-side h1 em { color: var(--gold); font-style: normal; }
.auth-side p { color: #a9b6cd; font-size: 14.5px; line-height: 1.7; max-width: 420px; margin-top: 14px; }
.auth-side ul { list-style: none; padding: 0; margin: 30px 0 0; display: grid; gap: 13px; }
.auth-side li { display: flex; gap: 11px; font-size: 13.5px; color: #c3cddd; align-items: center; }
.auth-side li .tick { color: var(--gold); font-weight: 800; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 26px; background: var(--bg); }
.auth-box { width: 100%; max-width: 392px; }
.auth-box h2 { font-size: 24px; color: var(--navy-900); }
.auth-box .sub { color: var(--muted); font-size: 13.5px; margin: 8px 0 26px; }

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-side { justify-content: flex-start; padding: 40px 56px 44px; }
}
@media (max-width: 640px) {
  .auth-side { padding: 28px 22px 30px; }
  .auth-side .auth-logo { width: 52px; height: 52px; }
  .auth-side h1 { font-size: 23px; margin-top: 16px; }
  .auth-side ul { margin-top: 18px; gap: 9px; }
  .auth-main { padding: 28px 20px 44px; }
}

.role-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.role-opt {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 8px; text-align: center;
  cursor: pointer; background: #fff; transition: all .15s; font-size: 11.5px; font-weight: 600; color: var(--navy-700);
}
.role-opt .ico { font-size: 19px; display: block; margin-bottom: 6px; }
.role-opt:hover { border-color: var(--navy-500); }
.role-opt.sel {
  border-color: var(--gold); background: var(--gold-soft); color: var(--navy-900);
  box-shadow: 0 4px 12px rgba(212,175,55,.25);
}

.auth-note {
  margin-top: 22px; padding: 13px 15px; background: #fff; border: 1px dashed var(--line);
  border-radius: 11px; font-size: 12px; color: var(--muted); line-height: 1.6;
}
.auth-note b { color: var(--navy-800); }
.demo-creds { display: grid; gap: 4px; margin-top: 8px; font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--navy-700); }

/* ---- Modal ------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,17,36,.55);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px; z-index: 100; overflow-y: auto;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 620px;
  box-shadow: var(--shadow-lg); animation: pop .2s ease; overflow: hidden;
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(14px) scale(.985); opacity: 0; } }
.modal-head {
  padding: 20px 24px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, #fff, #fafbfd);
}
.modal-head h3 { font-size: 16px; color: var(--navy-900); }
.modal-head .x { border: none; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 24px; max-height: 62vh; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfd; flex-wrap: wrap; }

/* ---- Toast ------------------------------------------------------------- */
.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: grid; gap: 10px; }
.toast {
  background: var(--navy-950); color: #fff; padding: 13px 18px; border-radius: 11px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); min-width: 250px; max-width: 380px;
  display: flex; gap: 11px; align-items: center; border-left: 4px solid var(--gold);
  animation: slideIn .22s ease;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

/* ---- Misc -------------------------------------------------------------- */
.section-title { font-size: 18px; color: var(--navy-900); margin-bottom: 4px; }
.section-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 18px; } .mt-3 { margin-top: 28px; }
.mb-1 { margin-bottom: 10px; } .mb-2 { margin-bottom: 18px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.detail-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 26px; }
.detail-list .k { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.detail-list .v { font-size: 14.5px; color: var(--navy-900); margin-top: 4px; font-weight: 500; }
@media (max-width: 640px) { .detail-list { grid-template-columns: 1fr; } }

.list { display: grid; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: all .15s;
}
.list-item:hover { border-color: #cfd7e5; }
.list-item .avatar-sm {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--navy-800); color: var(--gold); display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta b { display: block; font-size: 14px; color: var(--navy-900); }
.list-item .meta span { font-size: 12.5px; color: var(--muted); }

.check-row {
  display: flex; align-items: center; gap: 13px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 11px; cursor: pointer; transition: all .15s;
}
.check-row:hover { background: #fafbfd; border-color: var(--navy-500); }
.check-row input { width: 17px; height: 17px; accent-color: var(--navy-700); }
.check-row.checked { border-color: var(--gold); background: var(--gold-soft); }
.check-row .info { flex: 1; }
.check-row .info b { font-size: 13.5px; color: var(--navy-900); }
.check-row .info span { font-size: 12px; color: var(--muted); display: block; }

.search-bar { position: relative; margin-bottom: 14px; }
.search-bar input { padding-left: 38px; }
.search-bar::before { content: "⌕"; position: absolute; left: 14px; top: 9px; font-size: 17px; color: var(--muted); }

.alert { padding: 13px 16px; border-radius: 11px; font-size: 13px; line-height: 1.55; margin-bottom: 18px; }
.alert.warn { background: #fdf3d6; border: 1px solid #f0dfa5; color: #7a5b0b; }
.alert.info { background: #e7edf7; border: 1px solid #cdd9ec; color: var(--navy-700); }
.alert.err { background: #fdecea; border: 1px solid #f3c8c2; color: var(--danger); }

.copy-field { display: flex; gap: 8px; }
.copy-field input {
  font-family: ui-monospace, monospace; font-size: 12.5px; background: #fafbfd;
}
