:root {
  --bg: #f0f4f3;
  --surface: #ffffff;
  --ink: #1a2e2a;
  --muted: #5a716c;
  --brand: #0d6b5c;
  --brand-dark: #084c41;
  --accent: #c4a35a;
  --danger: #b33a3a;
  --ok: #1f7a4d;
  --border: #d5e2de;
  --shadow: 0 8px 24px rgba(13, 107, 92, 0.08);
  --radius: 10px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--ink); background: var(--bg); }
body.nav-open { overflow: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

.topbar {
  background: linear-gradient(120deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff !important;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
  line-height: 1.15;
}
.brand:hover { text-decoration: none; color: #fff !important; }
.brand .brand-text { color: #fff; overflow: hidden; text-overflow: ellipsis; }
.brand .brand-text span { color: var(--accent); }
.brand-logo {
  height: 44px;
  width: 44px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.userbox {
  font-size: 0.85rem;
  opacity: 0.95;
  text-align: right;
  max-width: 48%;
  line-height: 1.35;
  word-break: break-word;
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem 0.65rem;
}
.userbox .user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.userbox a,
.userbox a:link,
.userbox a:visited,
.userbox .logout-link {
  color: #1a2e2a !important;
  background: var(--accent);
  white-space: nowrap;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.userbox a:hover,
.userbox .logout-link:hover {
  filter: brightness(1.05);
  text-decoration: none !important;
}
.userbox .user-sep {
  display: none;
}

/* Hamburger — mobile only */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  position: relative;
}
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 56px);
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  margin: 0;
  border-radius: 0;
  color: var(--ink);
  font-weight: 500;
}
.sidebar > a {
  border-bottom: 1px solid var(--border);
}
.sidebar > a:last-child {
  border-bottom: none;
}
.sidebar a:hover, .sidebar a.active {
  background: rgba(13, 107, 92, 0.1);
  color: var(--brand-dark);
  text-decoration: none;
  border-radius: 8px;
}
.sidebar .nav-ico {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  color: var(--brand);
  opacity: 0.95;
}
.sidebar .nav-ico svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar a:hover .nav-ico,
.sidebar a.active .nav-ico {
  color: var(--brand-dark);
  opacity: 1;
}
.sidebar .nav-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.8rem 0.9rem 0.45rem;
  margin: 0 0 0.15rem;
  border-bottom: 2px solid var(--brand);
}

/* Accordion main menu groups */
.sidebar .nav-group {
  border-bottom: 1px solid var(--border);
}
.sidebar .nav-group-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}
.sidebar .nav-group-btn:hover {
  background: rgba(13, 107, 92, 0.08);
  color: var(--brand-dark);
  border-radius: 8px;
}
.sidebar .nav-group.is-open > .nav-group-btn {
  color: var(--brand-dark);
  background: rgba(13, 107, 92, 0.06);
  border-radius: 8px;
}
.sidebar .nav-group-title {
  flex: 1;
  min-width: 0;
}
.sidebar .nav-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
  margin-right: 0.15rem;
}
.sidebar .nav-group.is-open > .nav-group-btn .nav-chevron {
  transform: rotate(45deg);
  border-color: var(--brand);
}
.sidebar .nav-sub {
  display: none;
  padding: 0 0 0.35rem 0.35rem;
}
.sidebar .nav-group.is-open > .nav-sub {
  display: block;
}
.sidebar .nav-sub a {
  padding: 0.55rem 0.75rem 0.55rem 2.35rem;
  font-weight: 500;
  font-size: 0.92rem;
  border-bottom: none;
  color: var(--muted);
}
.sidebar .nav-sub a:hover,
.sidebar .nav-sub a.active {
  color: var(--brand-dark);
  background: rgba(13, 107, 92, 0.1);
  border-radius: 8px;
}
.sidebar .nav-group-btn .nav-ico {
  color: var(--brand);
}

.content {
  padding: 1.5rem;
  min-width: 0; /* allow grid child to shrink; tables scroll inside */
  max-width: 100%;
  overflow-x: visible;
}
.page-title { margin: 0 0 0.35rem; font-size: 1.6rem; word-wrap: break-word; }
.page-sub { margin: 0 0 1.25rem; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
a.card.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
a.card.card-link:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 14px rgba(13, 107, 92, 0.12);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
a.card.card-link:hover .value { color: var(--brand); }
.card .label { color: var(--muted); font-size: 0.85rem; }
.card .value { font-size: 1.15rem; font-weight: 700; margin-top: 0.25rem; color: var(--brand-dark); }
.card .card-go {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
  opacity: 0.75;
}
a.card.card-link:hover .card-go { opacity: 1; }

.card.card-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.card-dual-half {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.9rem 0.85rem;
  min-width: 0;
  transition: background 0.15s ease;
}
.card-dual-half + .card-dual-half {
  border-left: 1px solid var(--border);
}
.card-dual-half:hover {
  background: rgba(13, 107, 92, 0.06);
}
.card-dual-half:hover .value { color: var(--brand); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  max-width: 100%;
}
.panel h3 { margin: 0 0 0.9rem; font-size: 1.05rem; overflow: visible; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem 1rem;
  align-items: end;
}
.form-group { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.form-group label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=number],
.form-group input[type=date],
.form-group input[type=month],
.form-group input[type=email],
.form-group input[type=file],
.form-group select,
.form-group textarea,
input[type=text],
input[type=password],
input[type=number],
input[type=date],
input[type=month],
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
/* Mobile browsers: native date control often overflows container */
.form-group input[type="date"],
input[type="date"] {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}
.form-group textarea { min-height: 70px; resize: vertical; }
.form-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.btn,
input.btn,
input[type=submit].btn,
input[type=button].btn,
a.btn {
  display: inline-block;
  border: none !important;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand) !important;
  color: #fff !important;
  width: auto !important;
  text-decoration: none;
  text-align: center;
  line-height: 1.3;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover,
input.btn:hover,
a.btn:hover { background: var(--brand-dark) !important; color: #fff !important; text-decoration: none; }
.btn-secondary,
input.btn-secondary,
a.btn-secondary { background: #4a635e !important; }
.btn-secondary:hover,
input.btn-secondary:hover,
a.btn-secondary:hover { background: #354a46 !important; }
.btn-danger,
input.btn-danger,
a.btn-danger { background: var(--danger) !important; }
.btn-sm,
input.btn-sm,
a.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* Reports / grids — NEVER hide columns; scroll horizontally on small screens */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  position: relative;
}
.table-wrap::after {
  content: "swipe / scroll to see all columns";
  display: none;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
  background: #f6faf8;
  border-top: 1px solid var(--border);
}
table.grid {
  width: 100%;
  min-width: 640px; /* keep all report columns visible via scroll */
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 0;
}
table.grid th, table.grid td {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.55rem;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap; /* do not crush / hide cell text */
}
table.grid th a { color: var(--brand-dark); text-decoration: none; }
table.grid th a:hover { text-decoration: underline; }
table.grid th {
  background: rgba(13, 107, 92, 0.08);
  color: var(--brand-dark);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.grid tr:hover td { background: rgba(13, 107, 92, 0.03); }
table.grid td a { white-space: nowrap; }
.paid-on-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.paid-on-edit input[type="date"] {
  width: 9.5rem;
  max-width: 100%;
  padding: 0.3rem 0.4rem;
  font-size: 0.88rem;
}

/* Compact 2-col summary tables — full width, no forced scroll */
.table-wrap.compact table.grid,
table.grid.grid-sm {
  min-width: 0 !important;
  width: 100%;
}
.table-wrap.compact table.grid th,
.table-wrap.compact table.grid td,
table.grid.grid-sm th,
table.grid.grid-sm td {
  white-space: normal;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-ok { background: #d8f3e4; color: var(--ok); }
.badge-due { background: #fde2e2; color: var(--danger); }
.badge-warn { background: #fff3d6; color: #8a6a10; }
.badge-vacant { background: #fff3d6; color: #8a6a10; }

.msg { padding: 0.7rem 0.9rem; border-radius: 8px; margin-bottom: 1rem; word-wrap: break-word; }
.msg-ok { background: #d8f3e4; color: var(--ok); }
.msg-err { background: #fde2e2; color: var(--danger); }

.notice-board {
  margin-bottom: 1.35rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    linear-gradient(165deg, rgba(13, 107, 92, 0.07) 0%, rgba(255, 255, 255, 0.95) 42%, #fff 100%);
  box-shadow: var(--shadow);
}
.notice-board-head {
  padding: 1rem 1.15rem 0.85rem;
  background: linear-gradient(120deg, var(--brand-dark), var(--brand));
  color: #fff;
  position: relative;
}
.notice-board-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(196, 163, 90, 0.2));
}
.notice-board-kicker {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
}
.notice-board-sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  opacity: 0.88;
}
.notice-card {
  display: grid;
  grid-template-columns: 5px 1fr;
  gap: 0;
  margin: 0.85rem 0.9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: noticeIn 0.45s ease both;
}
.notice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(13, 107, 92, 0.12);
}
.notice-card:nth-child(2) { animation-delay: 0.05s; }
.notice-card:nth-child(3) { animation-delay: 0.1s; }
.notice-card:nth-child(4) { animation-delay: 0.15s; }
.notice-card:nth-child(5) { animation-delay: 0.2s; }
.notice-card-accent {
  background: linear-gradient(180deg, var(--brand), var(--accent));
}
.notice-card:first-of-type .notice-card-accent,
.notice-board > .notice-card:first-child .notice-card-accent {
  background: linear-gradient(180deg, var(--accent), var(--brand));
}
.notice-card-body {
  padding: 0.9rem 1rem 0.85rem;
  min-width: 0;
}
.notice-title {
  font-weight: 800;
  color: var(--brand-dark);
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  line-height: 1.35;
}
.notice-body {
  color: var(--ink);
  line-height: 1.6;
  font-size: 0.95rem;
}
.notice-meta {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.notice-date,
.notice-by {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(13, 107, 92, 0.08);
  color: var(--brand-dark);
  font-weight: 600;
}
.notice-by {
  background: rgba(196, 163, 90, 0.18);
  color: #7a5f22;
}
@keyframes noticeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .notice-card { animation: none; }
  .notice-card:hover { transform: none; }
}

/* Hindi / Devanagari friendly text */
.lang-hi,
.notice-title,
.notice-body,
textarea.lang-hi,
input.lang-hi {
  font-family: "Noto Sans Devanagari", "Mangal", "Segoe UI", Tahoma, sans-serif;
}

.dues-list-total {
  margin-top: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: rgba(13, 107, 92, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--ink);
}
table.grid tfoot td {
  background: rgba(13, 107, 92, 0.1);
  font-weight: 700;
  border-top: 2px solid var(--brand);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(196,163,90,0.25), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(13,107,92,0.25), transparent 35%),
    linear-gradient(160deg, #e8f2ef, #f7f3e8);
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 14px;
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.login-card h1 { margin: 0 0 0.25rem; color: var(--brand-dark); font-size: 1.5rem; }
.login-card .login-logo {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 0.85rem;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.login-card .hint { color: var(--muted); margin-bottom: 1.25rem; font-size: 0.92rem; }
.login-card .form-group { margin-bottom: 0.85rem; }
.login-card .btn { width: 100% !important; margin-top: 0.4rem; }
a.btn.login-choice-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  margin-top: 0.65rem;
  line-height: 1.25;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}
.demo-box {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: #f6faf8;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}
.login-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  background: #f0f6f4;
  padding: 0.3rem;
  border-radius: 10px;
}
.login-tab {
  flex: 1;
  text-align: center;
  padding: 0.55rem 0.4rem;
  border-radius: 8px;
  color: var(--muted) !important;
  font-weight: 600;
  text-decoration: none !important;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
}
.login-tab.active {
  background: #fff;
  color: var(--brand-dark) !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
a.login-tab { display: block; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
}

.select2-container .select2-selection--single {
  height: 38px !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 4px 8px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 28px !important;
  color: var(--ink) !important;
  padding-left: 2px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px !important;
}
.select2-dropdown {
  border-color: var(--border) !important;
  border-radius: 8px !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--brand) !important;
}
.select2-search__field {
  border-radius: 6px !important;
  padding: 6px 8px !important;
}
.expense-filter {
  align-items: end;
  grid-template-columns: 210px minmax(180px, 260px) auto !important;
}
.form-group-month {
  max-width: 210px;
  flex: 0 0 210px;
}
.form-group-type {
  max-width: 260px;
}
.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}
input[type="month"].month-picker,
.month-picker {
  display: block;
  width: 100% !important;
  max-width: 200px !important;
  min-height: 40px;
  height: 40px;
  padding: 0.35rem 0.55rem !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  background: #fff !important;
  color: var(--ink) !important;
  font: inherit !important;
  font-size: 0.95rem !important;
  line-height: 1.2 !important;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input[type="month"].month-picker:focus,
.month-picker:focus {
  outline: 2px solid rgba(13, 107, 92, 0.28);
  outline-offset: 1px;
  border-color: var(--brand) !important;
}

@media (max-width: 900px) {
  .expense-filter {
    grid-template-columns: 1fr !important;
  }
  .form-group-month,
  .form-group-type {
    max-width: 100%;
  }
  input[type="month"].month-picker,
  .month-picker {
    max-width: 100% !important;
  }
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 40, 35, 0.45);
  z-index: 90;
}

/* ===== Tablet / Mobile ===== */
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }

  /* Two-row sticky header */
  .topbar {
    display: grid !important;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-items: stretch;
    gap: 0;
    padding: 0.55rem 0.7rem 0.6rem;
    z-index: 120; /* above drawer */
  }
  .topbar-main {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
  }
  .brand {
    font-size: 1.02rem !important;
    max-width: calc(100% - 52px);
    flex: 1 1 auto;
  }
  .brand-logo {
    height: 38px;
    width: 38px;
  }
  .userbox {
    grid-column: 1;
    grid-row: 2;
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0.4rem 0 0;
    padding: 0.5rem 0 0.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    text-align: left !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 0.75rem !important;
    line-height: 1.35;
    position: relative;
    z-index: 1;
    gap: 0.65rem !important;
  }
  .userbox .user-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    text-overflow: unset;
    word-break: break-word;
    padding-right: 0.25rem;
  }
  .userbox a,
  .userbox .logout-link {
    margin-left: 0 !important;
    flex: 0 0 auto;
    font-size: 0.92rem !important;
    padding: 0.55rem 1rem !important;
    min-height: 40px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  /* Drawer starts BELOW full header — no overwrite */
  .nav-backdrop {
    top: var(--mobile-header-h, 6.9rem);
    z-index: 110;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: var(--mobile-header-h, 6.9rem);
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: auto;
    z-index: 115;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 28px rgba(0,0,0,0.18);
    padding: 0.55rem 0.65rem 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
  }
  .sidebar.is-open { display: block; }
  body.nav-open .nav-backdrop { display: block; }

  .sidebar .nav-label {
    margin: 0.35rem 0.35rem 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--brand);
  }

  .sidebar > a,
  .sidebar .nav-group-btn {
    padding: 0.8rem 0.85rem;
    font-size: 0.98rem;
  }

  .sidebar .nav-sub a {
    padding: 0.7rem 0.85rem 0.7rem 2.2rem;
    font-size: 0.95rem;
  }

  .sidebar a {
    margin: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .nav-sub a {
    border-bottom: none;
  }
  .sidebar > a:last-child {
    border-bottom: none;
  }
  .sidebar a:hover,
  .sidebar a.active {
    background: rgba(13, 107, 92, 0.08);
    border-radius: 8px;
  }

  .content {
    padding: 1rem 0.75rem 1.5rem;
  }
  .page-title { font-size: 1.35rem; }
  .panel { padding: 0.95rem 0.8rem; }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }
  .card .value { font-size: 1.2rem; }

  .table-wrap::after { display: block; }
  table.grid {
    min-width: 720px;
    font-size: 0.88rem;
  }
  table.grid th, table.grid td {
    padding: 0.55rem 0.45rem;
  }

  .btn, input.btn, a.btn {
    min-height: 42px;
    padding: 0.6rem 1rem;
  }
  .form-actions .btn,
  .form-actions input.btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  .brand { font-size: 0.98rem !important; }
  .userbox { font-size: 0.7rem !important; }
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }
  .card {
    padding: 0.75rem 0.7rem;
  }
  .card .label { font-size: 0.75rem; }
  .card .value { font-size: 1.05rem; word-break: break-word; }
  table.grid { min-width: 680px; }
  .login-card { padding: 1.25rem 1rem; }
}
