:root {
  --bg: #f7f7f7;
  --panel: #ffffff;
  --text: #223548;
  --muted: #5b738b;
  --line: #d5dadd;
  --accent: #0a6ed1;
  --accent-dark: #0854a0;
  --shell: #354a5f;
  --shell-dark: #233545;
  --table-head: #f2f4f5;
  --danger: #b93838;
  --shadow: 0 1px 2px rgba(34, 54, 73, 0.14);
}

:root[data-theme="ocean"] {
  --bg: #f5f9fc;
  --panel: #ffffff;
  --text: #123047;
  --muted: #557187;
  --line: #cbdbe7;
  --accent: #0877b9;
  --accent-dark: #075b8c;
  --shell: #17445f;
  --shell-dark: #0d2f45;
  --table-head: #eaf3f8;
}

:root[data-theme="forest"] {
  --bg: #f6faf7;
  --panel: #ffffff;
  --text: #173426;
  --muted: #5a7566;
  --line: #cdded3;
  --accent: #177245;
  --accent-dark: #0f5634;
  --shell: #234735;
  --shell-dark: #162f23;
  --table-head: #edf6f0;
}

:root[data-theme="indigo"] {
  --bg: #f8f7fc;
  --panel: #ffffff;
  --text: #242943;
  --muted: #626889;
  --line: #d8d8ea;
  --accent: #4f46b5;
  --accent-dark: #37308b;
  --shell: #302f59;
  --shell-dark: #22213e;
  --table-head: #efeffa;
}

:root[data-theme="graphite"] {
  --bg: #f4f5f5;
  --panel: #ffffff;
  --text: #20272c;
  --muted: #5f6a71;
  --line: #d0d5d8;
  --accent: #3f5968;
  --accent-dark: #2f414c;
  --shell: #2f3a42;
  --shell-dark: #1f282e;
  --table-head: #eceff1;
}

:root[data-theme="maroon"] {
  --bg: #faf6f7;
  --panel: #ffffff;
  --text: #3a1f2a;
  --muted: #7a5c67;
  --line: #e0ccd3;
  --accent: #9b2444;
  --accent-dark: #741b33;
  --shell: #4b2633;
  --shell-dark: #331923;
  --table-head: #f7eaf0;
}

:root[data-theme="amber"] {
  --bg: #faf8f2;
  --panel: #ffffff;
  --text: #2f2b1f;
  --muted: #766b54;
  --line: #ded5c2;
  --accent: #a66a00;
  --accent-dark: #7c4f00;
  --shell: #59462a;
  --shell-dark: #3d301d;
  --table-head: #f7f0e1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

.app-shell.menu-hidden {
  grid-template-columns: 1fr;
}

.app-shell.menu-hidden .sidebar {
  display: none;
}

.hidden { display: none !important; }

.route-field-hidden,
.form-grid [hidden] {
  display: none !important;
}

.login-root {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(10,110,209,0.14), rgba(53,74,95,0.04)),
    var(--bg);
}

.login-card {
  width: min(900px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.login-card-single {
  width: min(460px, 100%);
  grid-template-columns: 1fr;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-panel h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-panel p {
  color: var(--muted);
  margin: 0 0 18px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-message {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

.login-copyright {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(10,110,209,0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(10,110,209,0.06), rgba(255,255,255,0.86));
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.login-copyright span,
.login-copyright strong,
.login-copyright em {
  display: block;
}

.login-copyright strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.login-copyright em {
  margin-top: 6px;
  color: var(--accent-dark);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.login-copyright a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.login-copyright a:hover {
  text-decoration: underline;
}

.sidebar {
  background: var(--shell-dark);
  color: #fff;
  padding: 18px 14px;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
  margin-bottom: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #0a6ed1 0%, #2b78c5 55%, #49a3e8 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 10px 22px rgba(0,0,0,0.18);
  font-weight: 700;
  position: relative;
  overflow: hidden;
}

.brand-mark span {
  font-size: 20px;
  line-height: 1;
}

.brand-mark i {
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-size: 8px;
  font-style: normal;
  color: #ffe2a5;
}

.brand small {
  display: block;
  color: #d2dce5;
  margin-top: 4px;
}

.sidebar-menu-toggle {
  width: 100%;
  min-height: 34px;
  margin: 0 0 10px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-menu-toggle strong {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  font-size: 18px;
  line-height: 1;
}

.menu-reveal {
  position: fixed;
  left: 0;
  top: 86px;
  z-index: 80;
  width: 26px;
  height: 58px;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: var(--shell-dark);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 24px;
  cursor: pointer;
}

nav button,
nav a {
  width: 100%;
  min-height: 40px;
  border: 0;
  color: #dbe7f1;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: flex;
  align-items: center;
}

nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.38) transparent;
}

nav::-webkit-scrollbar {
  width: 8px;
}

nav::-webkit-scrollbar-track {
  background: transparent;
}

nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.28);
  border-radius: 999px;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-parent {
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.nav-chevron {
  margin-left: auto;
  color: rgba(255,255,255,0.68);
  font-size: 12px;
}

.nav-children {
  display: grid;
  gap: 2px;
  margin: 2px 0 8px 10px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid rgba(255,255,255,0.16);
}

nav a.nav-child {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #c8d6e2;
  font-weight: 400;
}

nav a.nav-child.active,
nav a.nav-child:hover {
  background: rgba(10,110,209,0.42);
  color: #fff;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-group + .nav-group {
  margin-top: 4px;
}

.nav-group-toggle {
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.72);
  background: rgba(255,255,255,0.05);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  justify-content: space-between;
}

.nav-group-toggle:hover,
.nav-group.expanded .nav-group-toggle {
  color: #fff;
  background: rgba(10,110,209,0.22);
}

.nav-group-links {
  display: grid;
  gap: 2px;
  padding: 2px 0 4px 8px;
  border-left: 1px solid rgba(255,255,255,0.12);
  margin-left: 4px;
}

nav button.active,
nav button:hover,
nav a.active,
nav a:hover {
  background: rgba(255,255,255,0.16);
  color: #fff;
}

.main { min-width: 0; }

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(34, 54, 73, 0.06);
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 { font-size: 20px; }

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.page-path {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 3px 8px;
  border: 1px solid #d8e4ef;
  border-radius: 999px;
  background: #f4f8fb;
  color: #31516f;
  font-size: 11px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.menu-toggle {
  white-space: nowrap;
}

.entity-switch,
.theme-switch {
  min-width: 220px;
  color: var(--muted);
}

.theme-switch {
  min-width: 150px;
}

.view { padding: 24px 28px 36px; }

.help-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.help-card {
  display: grid;
  gap: 6px;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  background: #fff;
  box-shadow: var(--shadow);
}

.help-card:hover {
  border-color: var(--accent);
}

.help-card span {
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats { grid-template-columns: repeat(4, minmax(150px, 1fr)); }

.stat, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.stat { padding: 18px; }
.stat small { color: var(--muted); }

.stat strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

select.searchable-native {
  background-image: linear-gradient(45deg, transparent 50%, #68737d 50%), linear-gradient(135deg, #68737d 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

input[readonly] {
  background: #f3f6f8;
  color: #5b738b;
}

.ops-control-block {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdff;
}

.ops-control-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.ops-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.ops-check {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  gap: 9px;
  padding: 10px;
  border: 1px solid #dbe5ee;
  border-radius: 6px;
  background: #fff;
}

.ops-check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.ops-check strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.ops-check small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.date-display-input {
  text-transform: uppercase;
}

.hidden-date-picker {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: 0;
}

.weight-warning {
  min-height: 0;
}

.warning-box {
  border: 1px solid #e5b84c;
  background: #fff8e6;
  color: #5a4100;
  border-radius: 8px;
  padding: 10px;
}

.warning-box table {
  margin-top: 8px;
  background: #fff;
}

select[multiple] {
  min-height: 132px;
}

.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }

.actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.ops-save-row {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.row-actions,
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.permission-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.permission-bulk-actions,
.permission-save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.permission-bulk-actions button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.permission-table-wrap {
  border: 1px solid var(--line);
  border-radius: 4px;
}

.permission-matrix th {
  white-space: nowrap;
}

.permission-matrix th,
.permission-matrix td {
  text-align: center;
  vertical-align: middle;
}

.permission-matrix .permission-module-name {
  text-align: left;
  font-weight: 700;
  color: var(--text);
  min-width: 210px;
}

.permission-matrix input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  accent-color: var(--accent);
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 4px;
  padding: 8px 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary,
a.secondary {
  background: #edf2f7;
  color: var(--text);
}

button.secondary:hover,
a.secondary:hover {
  background: #dfe8f0;
}

a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 4px;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 600;
}

a.page-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 4px;
  background: #edf2f7;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  font-weight: 600;
}

a.page-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.danger {
  background: var(--danger);
  color: #fff;
}

.danger-zone {
  border-color: rgba(185, 56, 56, 0.35);
  background: #fffafa;
}

.danger-zone summary {
  cursor: pointer;
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.link-button {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  font-weight: 700;
}

.photo-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
}

button.stat {
  color: var(--text);
  text-align: left;
}

.dashboard-command {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: stretch;
  padding: 20px;
  margin-bottom: 16px;
  border-radius: 8px;
  border: 1px solid #cbd7dc;
  background:
    linear-gradient(135deg, rgba(17,97,95,0.10), rgba(200,149,47,0.12)),
    #ffffff;
  box-shadow: var(--shadow);
}

.dashboard-command small {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.dashboard-command h2 {
  margin-top: 4px;
  font-size: 26px;
}

.dashboard-command p {
  margin: 6px 0 0;
  color: var(--muted);
}

.dashboard-command-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.dashboard-mini {
  min-width: 132px;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.dashboard-mini small {
  display: block;
  color: var(--muted);
  text-transform: none;
}

.dashboard-mini strong {
  display: block;
  margin-top: 4px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-hero-pro {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.6fr);
}

.dashboard-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dashboard-brand h2 {
  margin-bottom: 4px;
}

.dashboard-brand p {
  margin: 0;
  color: var(--muted);
}

.dashboard-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
}

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
  padding: 16px;
  min-height: 96px;
}

.dashboard-card small,
.chart-row small {
  color: var(--muted);
}

.dashboard-card strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  margin-top: 8px;
}

.dashboard-period-filter {
  padding: 14px 16px;
}

.dashboard-period-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-period-card {
  display: grid;
  gap: 10px;
  min-height: 168px;
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
}

.dashboard-period-card:hover {
  border-color: var(--accent);
  background: #f9fbfd;
}

.period-card-header {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.period-card-header strong {
  color: var(--text);
  font-size: 17px;
}

.period-card-header small,
.period-metric small {
  color: var(--muted);
}

.period-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.period-metric strong {
  color: var(--text);
  font-size: 18px;
  white-space: nowrap;
}

.dashboard-card.clickable,
.stat.clickable {
  cursor: pointer;
}

.dashboard-card.clickable:hover,
.stat.clickable:hover {
  border-color: var(--accent);
}

.dashboard-focus {
  min-height: 100%;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-title-row span {
  color: var(--muted);
  font-weight: 700;
}

.dashboard-pulse-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 14px;
}

.dashboard-donut {
  min-height: 190px;
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--text);
  background: #f7fafb;
  border: 1px solid var(--line);
}

.dashboard-donut:hover {
  border-color: var(--accent);
}

.donut-ring {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #ffffff 0 52%, transparent 53%),
    conic-gradient(var(--accent) var(--pct), #d8e1e5 0);
}

.dashboard-donut:nth-child(2) .donut-ring {
  background:
    radial-gradient(circle at center, #ffffff 0 52%, transparent 53%),
    conic-gradient(#b98226 var(--pct), #d8e1e5 0);
}

.dashboard-donut:nth-child(3) .donut-ring {
  background:
    radial-gradient(circle at center, #ffffff 0 52%, transparent 53%),
    conic-gradient(#5d6f86 var(--pct), #d8e1e5 0);
}

.donut-ring strong {
  max-width: 76px;
  text-align: center;
  font-size: 14px;
}

.dashboard-donut small {
  color: var(--muted);
  font-weight: 700;
}

.chart-list {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  gap: 5px;
}

.chart-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.chart-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf0;
}

.chart-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.chart-fill.warn { background: #b98226; }

.quick-list {
  display: grid;
  gap: 8px;
}

.quick-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  background: #f2f6f7;
}

.dashboard-expiry-scroll {
  max-height: 280px;
  overflow: auto;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-expiry-scroll .table-wrap {
  border: 0;
}

.expiry-alert-modal p {
  margin: 4px 0 0;
  color: var(--muted);
}

.filter-actions {
  align-self: end;
}

.user-chip {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.status-chip {
  align-self: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #e4f2ef;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.status-chip.offline {
  background: #fff4d8;
  color: #8a5b13;
}

.version-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

pre.audit-json {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f4f7f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 300px;
  overflow: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(10, 20, 25, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-window {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(10, 20, 25, 0.25);
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap {
  width: 100%;
  max-height: min(64vh, 680px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 0;
  border-radius: 4px;
  overflow: hidden;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  position: static;
  z-index: 1;
  background: var(--table-head);
  color: #223548;
}

.tableSortHeader {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  font-weight: 700;
}

.tableSortHeader:hover {
  background: transparent;
  color: var(--accent);
}

.table-filter-row th {
  top: 36px;
  background: #f8fafb;
  padding: 5px;
}

.tableColumnFilter {
  min-height: 30px;
  padding: 5px 7px;
  font-size: 11px;
}

tr:last-child td { border-bottom: 0; }

.table-limit-note {
  margin: 0 0 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f8f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-pager button {
  min-width: 86px;
}

.api-status {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.api-status.ok {
  border: 1px solid #b9d9ce;
  background: #eef8f4;
  color: var(--accent);
}

.api-status.warn {
  border: 1px solid #ecd3a8;
  background: #fff8ea;
  color: #8a5b13;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e4f2ef;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.badge-warn {
  background: #fff4d8;
  color: #8a5b13;
}

.badge-danger {
  background: #ffe7e7;
  color: var(--danger);
}

.badge-locked {
  background: #ffe7e7;
  color: var(--danger);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.report-grid { grid-template-columns: 1.2fr 1fr; }

.report-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.report-summary span {
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f8f8;
}

.report-summary strong {
  display: block;
  font-size: 18px;
}

.report-summary small {
  color: var(--muted);
}

.report-source {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.report-customizer {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
  padding: 10px 12px;
}

.report-customizer summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

.report-column-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px 12px;
  margin: 12px 0;
}

.report-column-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.report-column-list input {
  width: auto;
  min-height: 0;
}

.report-table-wrap {
  max-height: min(70vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.report-table-wrap table th,
.report-table-wrap table td {
  padding: 7px 8px;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    max-height: 62vh;
  }
  nav {
    display: block;
    max-height: calc(62vh - 86px);
    overflow-y: auto;
    gap: 6px;
  }
  .form-grid, .stats, .report-grid, .dashboard-hero, .dashboard-strip, .dashboard-pulse-grid, .login-card, .version-grid, .report-column-list, .ops-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .sidebar {
    padding: 12px;
    position: static;
  }
  .brand {
    padding-bottom: 12px;
    margin-bottom: 10px;
  }
  nav {
    max-height: 42vh;
    overflow: auto;
    padding-right: 2px;
    display: block;
  }
  nav button,
  nav a {
    min-height: 42px;
    padding: 10px;
  }
  .dashboard-command {
    flex-direction: column;
  }
  .dashboard-command-actions {
    justify-content: stretch;
  }
  .dashboard-mini {
    flex: 1 1 100%;
  }
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }
  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .top-actions > * {
    width: 100%;
  }
  .panel {
    padding: 14px;
    margin-bottom: 12px;
  }
  .main {
    min-width: 0;
  }
  input, select, textarea, button, a.page-link {
    min-height: 44px;
    font-size: 14px;
  }
  .actions, .row-actions, .report-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .row-actions button,
  .report-actions button {
    width: 100%;
  }
  .view { padding: 12px; }
  th, td {
    padding: 8px;
    font-size: 12px;
    white-space: nowrap;
  }
  .modal-backdrop {
    padding: 8px;
    align-items: start;
  }
  .modal-window {
    max-height: calc(100vh - 16px);
    padding: 14px;
  }
  nav, .form-grid, .stats, .report-grid, .dashboard-hero, .dashboard-strip, .dashboard-pulse-grid, .login-card, .version-grid, .report-column-list, .ops-check-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
