:root {
  --ink: #17243a;
  --muted: #667085;
  --paper: #f4f8fc;
  --card: #ffffff;
  --line: #dce3ee;
  --brand: #0b2d59;
  --brand-dark: #061f40;
  --brand-soft: #e8eef7;
  --accent: #4c72a6;
  --danger: #b64040;
  --danger-soft: #fff0ef;
  --shadow: 0 24px 70px rgba(19, 43, 78, .11);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f2f7fb 0%, #f8fafc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.ambient { display: none; }

.topbar {
  height: 84px;
  width: min(820px, calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: inline-flex; gap: 11px; align-items: center; color: var(--brand); text-decoration: none; font-size: 1.08rem; font-weight: 850; letter-spacing: -.02em; }
.brand-logo { width: 52px; height: 52px; object-fit: contain; }

.icon-button { width: 42px; height: 42px; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.7); color: var(--ink); display: grid; place-items: center; transition: .18s ease; }
.icon-button:hover { transform: translateY(-1px); border-color: #aebbd0; background: white; }
.icon-button svg { width: 20px; fill: currentColor; }
#adminOpen { width: auto; padding: 9px 13px; display: inline-flex; gap: 7px; color: var(--brand); border-color: #d4deeb; background: white; box-shadow: 0 6px 18px rgba(18, 43, 76, .08); font-weight: 780; }
#adminOpen:hover { color: white; border-color: var(--brand); background: var(--brand); }
#adminOpen svg { width: 17px; }

.page-shell { width: min(820px, calc(100% - 32px)); margin: 20px auto 96px; }
.hero { text-align: left; margin-bottom: 18px; }
.hero h1 { margin: 0; font-family: inherit; font-size: clamp(1.45rem, 4vw, 2rem); line-height: 1.15; font-weight: 820; letter-spacing: -.03em; color: var(--brand); }

.card { padding: clamp(24px, 5vw, 46px); border: 1px solid #dce5ef; border-radius: 26px; background: var(--card); box-shadow: 0 24px 60px rgba(24, 50, 83, .10); }
.card h2 { margin: 7px 0 5px; font-size: clamp(1.65rem, 4vw, 2.1rem); letter-spacing: -.035em; }
.step-label, .dialog-kicker { color: var(--brand); font-size: .71rem; font-weight: 850; text-transform: uppercase; letter-spacing: .12em; }
.muted { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }

.location-card { padding: 0; overflow: hidden; }
.form-card-head { padding: 22px 34px 18px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.form-card-headline { display: flex; align-items: center; justify-content: space-between; color: #66758b; font-size: .72rem; font-weight: 850; letter-spacing: .12em; }
.form-card-headline strong { color: #66758b; letter-spacing: .04em; }
.progress-track { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e9eef5; }
.progress-track span { display: block; width: 50%; height: 100%; border-radius: inherit; background: #1d5a9a; }
.location-card-body { padding: 38px 52px 46px; }
.step-index { margin-bottom: 12px; color: #1d5a9a; font-size: .78rem; font-weight: 900; letter-spacing: .11em; }
.location-select-form { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.select-control { position: relative; display: block; }
.select-control::after { content: ""; position: absolute; top: 50%; right: 16px; width: 8px; height: 8px; border-right: 2px solid #5f6f86; border-bottom: 2px solid #5f6f86; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.location-select-form select { min-height: 48px; padding-right: 44px; appearance: none; -webkit-appearance: none; font-weight: 650; border-color: #cdd8e6; background: #fff; }
.location-select-form .compact-next { min-height: 48px; min-width: 96px; padding: 9px 15px; box-shadow: 0 8px 18px rgba(11, 45, 89, .14); }

.empty-state { margin-top: 25px; padding: 28px; text-align: center; border-radius: 18px; border: 1px dashed #bcc8da; background: #fafbfe; }
.empty-state h3 { margin: 8px 0 5px; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-icon { margin: 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-size: 1.3rem; }

.section-topline { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 23px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--brand); font-weight: 750; }
.text-button:hover { text-decoration: underline; }
.status-badge { padding: 7px 10px; border-radius: 999px; color: #234c7b; background: #e8f0fa; font-size: .74rem; font-weight: 750; }
.status-badge.closed { color: #8b4843; background: var(--danger-soft); }
.selected-location { margin: 0 0 25px; color: var(--muted); }

.name-form { padding: 20px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; border-radius: 18px; background: #f2f5fa; }
label { display: grid; gap: 7px; color: var(--ink); font-weight: 700; font-size: .83rem; }
input, select, textarea { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid #cbd5e3; border-radius: 11px; color: var(--ink); background: white; outline: none; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 45, 89, .12); }
small { color: var(--muted); font-weight: 500; line-height: 1.4; }

.primary-button, .secondary-button, .danger-button { min-height: 45px; padding: 10px 16px; border-radius: 11px; font-weight: 780; border: 1px solid transparent; transition: .18s ease; }
.primary-button { color: white; background: var(--brand); box-shadow: 0 7px 18px rgba(11, 45, 89, .17); }
.primary-button:hover { background: var(--brand-dark); transform: translateY(-1px); }
.secondary-button { color: var(--ink); background: white; border-color: var(--line); }
.secondary-button:hover { border-color: #a9b7cc; }
.danger-button { color: white; background: var(--danger); }
.danger-button:hover { background: #963333; }
.full { width: 100%; }

.notice { margin-top: 16px; padding: 13px 15px; border-radius: 12px; color: #80514a; background: var(--danger-soft); line-height: 1.45; font-size: .9rem; }
.list-heading { margin: 32px 0 13px; display: flex; justify-content: space-between; align-items: baseline; gap: 15px; }
.list-heading h3 { margin: 0; font-size: 1.05rem; }
.list-heading span { color: var(--muted); font-size: .82rem; }
.entries-list { display: grid; gap: 9px; }
.entry-row { min-height: 60px; padding: 10px 12px 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.entry-person { min-width: 0; display: flex; align-items: center; gap: 12px; font-weight: 740; }
.entry-initials { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: var(--brand); background: var(--brand-soft); font-size: .75rem; }
.entry-actions { display: flex; gap: 7px; }
.mini-button { padding: 7px 9px; border: 0; border-radius: 9px; color: var(--brand); background: var(--brand-soft); font-size: .76rem; font-weight: 750; }
.mini-button.danger { color: var(--danger); background: var(--danger-soft); }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; }
.toast { max-width: min(390px, calc(100vw - 40px)); padding: 13px 16px; border-radius: 12px; color: white; background: var(--brand); box-shadow: 0 14px 40px rgba(11, 45, 89, .25); animation: toast-in .25s ease; }
.toast.error { background: #9c3939; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(9, 27, 51, .52); backdrop-filter: blur(5px); }
.admin-dialog { width: min(980px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 22px; background: #fafbfe; box-shadow: 0 25px 90px rgba(0,0,0,.28); }
.admin-dialog[open] { animation: dialog-in .2s ease; }
@keyframes dialog-in { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.dialog-head { position: sticky; top: 0; z-index: 2; padding: 23px 26px 17px; display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid var(--line); background: rgba(250,251,254,.96); backdrop-filter: blur(10px); }
.dialog-head h2 { margin: 3px 0 0; font-size: 1.6rem; letter-spacing: -.03em; }
.dialog-title-row { display: flex; align-items: center; gap: 10px; }
.role-badge { padding: 5px 8px; border-radius: 999px; color: #2a527f; background: #e7eef8; font-size: .68rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.role-badge.super { color: #7f3f25; background: #fff0e8; }
.dialog-close { border: 0; color: var(--brand); background: var(--brand-soft); font-size: 1.4rem; }
#adminLoginView, #adminPanel { padding: 25px 26px 28px; }
.stack-form { display: grid; gap: 15px; }
.admin-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 20px; }
.admin-actions-row .text-button { margin-left: auto; }
details { margin-top: 12px; border: 1px solid var(--line); border-radius: 15px; background: white; overflow: hidden; }
summary { padding: 16px 18px; cursor: pointer; font-weight: 780; list-style-position: inside; }
.details-body { padding: 5px 18px 18px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.bulk-location-form { display: grid; gap: 12px; }
.bulk-location-form textarea { min-height: 112px; line-height: 1.5; }
.bulk-location-form .primary-button { justify-self: start; }
.bulk-columns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.import-preview { padding: 10px 12px; border-radius: 10px; color: #43546b; background: #edf2f8; font-size: .82rem; font-weight: 700; }
.admin-location-list, .admin-entry-list { margin-top: 13px; display: grid; gap: 8px; }
.admin-location, .admin-entry { padding: 11px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-radius: 11px; background: #f1f4f9; }
.admin-location strong, .admin-entry strong { overflow-wrap: anywhere; }
.admin-meta { color: var(--muted); font-size: .74rem; font-weight: 500; }
.filter-label { margin-bottom: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card { padding: 15px; display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 13px; background: #f6f8fc; }
.stat-card span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.stat-card strong { color: var(--brand); font-size: 1.65rem; line-height: 1; }
.table-toolbar { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr 1fr; gap: 10px; margin-bottom: 12px; }
.compact-toolbar { grid-template-columns: 1fr 1fr; }
.table-actions { margin: 4px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .8rem; }
.small-button { min-height: 38px; padding: 7px 11px; font-size: .78rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: white; }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th, .data-table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #e8edf4; white-space: nowrap; }
.data-table th { color: #58677c; background: #f6f8fb; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8fafd; }
.number-cell { text-align: right !important; font-variant-numeric: tabular-nums; }
.column-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 14px; }
.column-options label { padding: 9px 10px; display: flex; grid-template-columns: none; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: white; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--brand); }
.compact-copy { margin-bottom: 12px; }
.danger-zone { border-color: #efcccc; }
.danger-zone summary { color: var(--danger); }
.danger-zone p { color: var(--muted); line-height: 1.5; }

.confirm-dialog { width: min(450px, calc(100% - 28px)); padding: 25px; border: 0; border-radius: 18px; box-shadow: 0 25px 90px rgba(0,0,0,.3); }
.confirm-dialog h2 { margin: 0 0 8px; }
.confirm-dialog p { color: var(--muted); line-height: 1.5; }
.confirm-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 9px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 680px) {
  .topbar { width: calc(100% - 28px); }
  .brand { gap: 8px; font-size: .98rem; }
  .brand-logo { width: 46px; height: 46px; }
  #adminOpen { min-height: 40px; padding: 8px 10px; }
  #adminOpen span { display: none; }
  .page-shell { margin-top: 12px; }
  .location-card-body { padding: 30px 24px 34px; }
  .form-card-head { padding: 18px 24px 15px; }
  .location-select-form { grid-template-columns: 1fr; }
  .location-select-form .primary-button { justify-self: end; width: auto; }
  .name-form { grid-template-columns: 1fr; }
  .section-topline { align-items: flex-start; flex-direction: column; }
  .entry-row { align-items: flex-start; }
  .entry-actions { flex-direction: column; }
  .admin-actions-row > * { flex: 1 1 auto; }
  .admin-actions-row .text-button { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table-toolbar, .compact-toolbar, .bulk-columns { grid-template-columns: 1fr; }
  .column-options { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
