:root {
  --ink: #1c2430;
  --muted: #5c6b7a;
  --line: #d7dee6;
  --paper: #f4f1ea;
  --white: #fff;
  --navy: #1b365d;
  --navy-2: #152a48;
  --gold: #b08d2e;
  --green: #1f7a4d;
  --red: #a33b32;
  --shadow: 0 10px 30px rgba(21, 42, 72, 0.12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Segoe UI", Calibri, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  overscroll-behavior: contain;
}
button, a, input, select, label { touch-action: manipulation; }
button, input, select { font: inherit; font-size: 16px; }
button { cursor: pointer; -webkit-tap-highlight-color: rgba(176, 141, 46, 0.25); }

.lock-banner {
  background: #a33b32;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
}
.impersonate-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  background: var(--navy);
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
}
.impersonate-banner[hidden] { display: none; }
.impersonate-banner .btn {
  background: var(--gold);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
}
body.license-locked #view button:not(#show-activity),
body.license-locked #view input:not(.date-text):not(.date-native):not(#y),
body.license-locked #view select:not(#m):not(#qra-y):not(#qra-m):not(#activity-user),
body.license-locked #view textarea {
  pointer-events: none;
}

.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(16px, var(--safe-t)) 16px max(16px, var(--safe-b));
  background: radial-gradient(circle at top, #2a4d82, var(--navy-2));
}
.login-card {
  width: min(420px, 100%);
  background: var(--white);
  padding: 28px 22px 32px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border-top: 6px solid var(--gold);
}
.logo-nura {
  margin: 4px 0 22px;
  text-align: center;
  line-height: 0;
}
.logo-nura img {
  width: min(168px, 56vw);
  height: auto;
  display: inline-block;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(21, 42, 72, 0.12);
}
.login-card h1 { margin: 6px 0 0; font-family: Georgia, serif; color: var(--navy); }
.kicker { margin: 0; color: var(--gold); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.sub { color: var(--muted); margin: 0 0 24px; }
.login-card label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.login-card input, .field input, .field select, table input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  min-height: 44px;
  width: 100%;
  max-width: 100%;
}
.date-wrap {
  position: relative;
  display: block;
}
.date-wrap .date-text {
  padding-right: 2.75rem;
  letter-spacing: 0.02em;
}
.field .date-wrap .date-native {
  position: absolute;
  top: 0;
  right: 0;
  width: 2.75rem;
  max-width: 2.75rem;
  min-height: 44px;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  background: transparent;
  z-index: 2;
}
.date-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231b365d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
}
.login-card button, .btn {
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 44px;
}
.login-card button { width: 100%; margin-top: 8px; }
.btn.gold { background: var(--gold); color: #1c1608; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
#activity-box { margin-top: 8px; }
.btn.danger { background: var(--red); }
.error { color: var(--red); font-size: 14px; }

.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: calc(8px + var(--safe-t)) 14px 8px;
  background: var(--navy-2);
  color: #e8eef6;
  font-weight: 600;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: inherit;
  font-size: 22px;
  line-height: 1;
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 32, 0.45);
  z-index: 45;
}

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: var(--navy-2);
  color: #e8eef6;
  display: flex;
  flex-direction: column;
  padding: 20px 14px calc(16px + var(--safe-b));
}
.brand { display: flex; gap: 10px; align-items: center; padding: 8px 8px 20px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gold); color: #1c1608; font-weight: 700;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
}
.mobile-brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
}
.brand small { display: block; color: #b9c6d6; }
.muted-cell { color: var(--muted); }
a.week-jump {
  color: var(--navy);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid rgba(27, 54, 93, 0.35);
}
a.week-jump:hover { color: var(--gold); border-bottom-color: var(--gold); }

.report-frame {
  border: 2px solid var(--navy);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px rgba(176, 141, 46, 0.55);
}
.report-frame-head {
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, #f7f1e3 0%, #eef3f8 100%);
  border-bottom: 2px solid var(--navy);
  text-align: center;
}
.report-frame-head h3 {
  margin: 4px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--navy);
  font-size: 1.15rem;
  line-height: 1.35;
}
.report-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.report-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.report-frame .table-wrap {
  margin: 0;
  border: 0;
}
.report-frame table.data {
  min-width: 640px;
  border-collapse: collapse;
}
.report-frame table.data th,
.report-frame table.data td {
  border: 1px solid #8fa3b8;
  padding: 10px 8px;
}
.report-frame table.data thead th {
  background: var(--navy);
  color: #f4f7fb;
  font-weight: 700;
  vertical-align: middle;
}
.report-frame table.data thead th a.week-jump {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.45);
}
.report-frame table.data thead th a.week-jump:hover {
  color: #f0d789;
  border-bottom-color: #f0d789;
}
.report-frame table.data tbody td.left {
  background: #f3f6fa;
  font-weight: 600;
  color: var(--navy);
  min-width: 210px;
}
.report-frame table.data tbody tr:nth-child(even) td:not(.left) {
  background: #fafbfd;
}
.report-frame table.data .col-total {
  background: #f7f1e3 !important;
  font-weight: 700;
  color: var(--navy);
}
.report-frame table.data .col-open,
.report-frame table.data .col-end {
  background: #eef5ee !important;
  font-weight: 600;
}
.report-frame table.data input {
  border: 1px solid #8fa3b8;
  background: #fff;
  border-radius: 6px;
}
.report-frame-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid #8fa3b8;
  background: #f8fafc;
  font-size: 12px;
  color: var(--muted);
}
.report-frame-actions {
  margin-top: 14px;
}
.sidebar nav { display: grid; gap: 6px; flex: 1; }
.sidebar a {
  color: inherit; text-decoration: none; padding: 12px;
  border-radius: 8px; min-height: 44px; display: flex; align-items: center;
}
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,0.08); }
.sidebar-foot { padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
#who { display: block; font-size: 13px; color: #b9c6d6; word-break: break-word; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.row-actions .btn { padding: 8px 10px; min-height: 40px; font-size: 13px; }
table.data input.name-in {
  width: 120px;
  min-height: 40px;
  text-align: left;
  padding: 6px 8px;
}
.sidebar-foot button {
  margin-top: 8px; width: 100%; background: transparent; color: #e8eef6;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; padding: 10px;
  min-height: 44px;
}

.main {
  padding: 28px 32px calc(48px + var(--safe-b));
  padding-left: max(32px, var(--safe-l));
  padding-right: max(32px, var(--safe-r));
  min-width: 0;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.top-copy { min-width: 0; flex: 1; }
.top h1 { margin: 0; font-family: Georgia, serif; color: var(--navy); }
.top p { margin: 6px 0 22px; color: var(--muted); }
.desktop-bell {
  background: var(--navy-2);
  color: #e8eef6;
  flex-shrink: 0;
}
.mobile-bar span { flex: 1; min-width: 0; }
.bell-btn { position: relative; }
.bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c4473a;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
}
.bell-panel {
  position: fixed;
  z-index: 60;
  top: calc(64px + var(--safe-t));
  right: max(16px, var(--safe-r));
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.bell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.bell-head .btn { min-height: 36px; padding: 6px 10px; font-size: 13px; width: auto; }
.bell-item {
  border-top: 1px solid var(--line);
  padding: 10px 4px;
}
.bell-item.unread { background: #f7f1e3; margin: 0 -8px; padding-left: 12px; padding-right: 12px; border-radius: 8px; border-top: 0; }
.bell-item strong { display: block; color: var(--navy); font-size: 14px; }
.bell-item p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.bell-item small { color: var(--muted); font-size: 12px; }
.bell-empty { color: var(--muted); padding: 16px 8px; }
.license-ok { border-top: 5px solid var(--green); }
.license-warn { border-top: 5px solid var(--gold); }
.license-bad { border-top: 5px solid var(--red); }
.office-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.office-tabs a { text-decoration: none; }
.bell-group {
  margin: 12px 4px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--navy);
}
.office-block section { margin-top: 18px; }
.office-block h4 { margin: 0 0 8px; color: var(--navy); }
.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.admin-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.super-offices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 700px) {
  .super-offices { grid-template-columns: 1fr; }
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.8);
  min-width: 0;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.field { display: grid; gap: 6px; font-size: 14px; min-width: min(220px, 100%); flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0 -4px 8px;
}
.swipe-hint { display: none; font-size: 12px; color: var(--muted); margin: 0 0 8px; }

table.data { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 14px; }
table.data.compact { min-width: 0; width: auto; max-width: 100%; }
table.data.compact th:not(.left),
table.data.compact td:not(.left) {
  width: 1%;
  white-space: nowrap;
}
table.data th, table.data td { border: 1px solid var(--line); padding: 8px; text-align: center; }
table.data th { background: #eef3f8; color: var(--navy); }
table.data td.left, table.data th.left { text-align: left; }
table.data input {
  width: 72px;
  min-height: 44px;
  text-align: center;
  padding: 8px;
}
table.data input[readonly] {
  background: #eef3f8;
  color: var(--ink);
}
table.data tfoot td { font-weight: 700; background: #f7f1e3; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.section-title {
  font-family: Georgia, serif;
  color: var(--navy);
  font-size: 1.15rem;
  margin: 8px 0 12px;
}
.ok { color: var(--green); font-weight: 600; }

#toast {
  position: fixed;
  right: max(16px, var(--safe-r));
  bottom: max(16px, var(--safe-b));
  left: auto;
  background: var(--navy); color: #fff; padding: 12px 16px;
  border-radius: 10px; box-shadow: var(--shadow);
  max-width: min(360px, calc(100vw - 32px));
  z-index: 50;
}

.user-perms { display: flex; gap: 14px; flex-wrap: wrap; }
.user-perms label { display: flex; gap: 8px; align-items: center; min-height: 44px; }
.user-perms input { width: 20px; height: 20px; min-height: 20px; }
.perm-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.perm-groups fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0;
  padding: 10px 14px 12px;
  background: #f7fafc;
}
.perm-groups legend {
  font-weight: 700;
  color: var(--navy);
  padding: 0 6px;
}
.perm-groups label {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
}
.perm-groups fieldset.perm-daily {
  background: #eef5ee;
  border-color: #c5d9c8;
}
.perm-groups fieldset.perm-daily p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.daily-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.perm-groups input,
table.data td.perm-cell input {
  width: 20px;
  height: 20px;
  min-height: 20px;
}

@media (min-width: 901px) {
  .app { grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar {
    width: 250px;
    min-width: 250px;
    max-width: 250px;
  }
  .sidebar nav {
    flex: 0 1 auto;
    align-content: start;
  }
  .sidebar-foot {
    margin-top: auto;
  }
}

@media (max-width: 900px) {
  .mobile-bar { display: flex; }
  .desktop-bell { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .main { padding: 16px 14px 96px; }
  .swipe-hint { display: block; }
  table.data { font-size: 13px; }
  .toolbar .btn, .toolbar .field { width: 100%; }
  .toolbar .btn { text-align: center; }
  .daily-actions {
    position: fixed;
    left: max(12px, var(--safe-l));
    right: max(12px, var(--safe-r));
    bottom: max(12px, var(--safe-b));
    z-index: 30;
    width: auto;
  }
  .daily-actions .btn { flex: 1; text-align: center; }
  #toast { bottom: max(72px, calc(var(--safe-b) + 60px)); left: 16px; right: 16px; max-width: none; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    padding-top: calc(16px + var(--safe-t));
  }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .nav-backdrop { display: block; }
  body.menu-open { overflow: hidden; }
}

@media (max-width: 480px) {
  .top h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  table.data input { width: 64px; }
}

.qra-group td {
  background: #eef3f8;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--navy);
}
.qra-more {
  margin: 0 0 16px;
  background: var(--white);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.qra-more summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--navy);
  padding: 8px 0;
}
.qra-more .card { box-shadow: none; margin: 12px 0 0; }
.qra-cash-table td.muted-cell { white-space: nowrap; }
