/*
 * MikBoX UI — soft, rounded dashboard theme.
 * Palette follows the MikBoX logo (assets/brand). Change --app-primary (+ hover/soft) in both theme blocks.
 */
:root {
  color-scheme: light;
  --app-bg: #F4F7FA;
  --app-surface: #FFFFFF;
  --app-surface-raised: #FFFFFF;
  --app-surface-muted: #EDF2F7;
  --app-text: #172A45;
  --app-text-muted: #55677F;
  --app-border: #DEE5ED;
  --app-primary: #4A799B;
  --app-on-primary: #FFFFFF;
  --app-primary-hover: #3D6886;
  --app-primary-soft: #E5EEF5;
  --app-on-primary-soft: #2F5675;
  --app-success: #167D60;
  --app-warning: #9A640C;
  --app-danger: #BE3F50;
  --app-focus: rgba(74, 121, 155, .4);
  --app-shadow: 0 12px 36px rgba(23, 42, 69, .07);
  --app-shadow-sm: 0 4px 14px rgba(23, 42, 69, .05);
  --app-radius-card: 24px;
  --app-radius-control: 14px;
  --app-radius-pill: 999px;
  --app-tint: 14%;
  --app-sidebar-w: 264px;
  --tone-blue: #3B82F6;
  --tone-indigo: #6366F1;
  --tone-purple: #8B5CF6;
  --tone-pink: #EC4899;
  --tone-red: #E5484D;
  --tone-orange: #F97335;
  --tone-yellow: #E5A00D;
  --tone-green: #22A06B;
  --tone-teal: #14B8A6;
  --tone-cyan: #0EA5C6;
  --tone-grey: #7C8691;
  --tone-dark: #2B2D34;
  --tone-sky: #38BDF8;
  --app-chart-1: #4A799B;
  --app-chart-2: #E8833A;
  --font: "Plus Jakarta Sans", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #101824;
  --app-surface: #17223A;
  --app-surface-raised: #1D2A44;
  --app-surface-muted: #22314D;
  --app-text: #E3EBF5;
  --app-text-muted: #9FB1C7;
  --app-border: #2C3B57;
  --app-primary: #6EA3CA;
  --app-on-primary: #0E1A2B;
  --app-primary-hover: #86B4D6;
  --app-primary-soft: #1E3552;
  --app-on-primary-soft: #9CC4E2;
  --app-success: #5FD0A8;
  --app-warning: #F7C366;
  --app-danger: #F28E94;
  --app-focus: rgba(110, 163, 202, .45);
  --app-shadow: 0 16px 48px rgba(0, 0, 0, .28);
  --app-shadow-sm: 0 4px 16px rgba(0, 0, 0, .22);
  --app-tint: 20%;
  --tone-dark: #9AA3AD;
  --app-chart-1: #6EA3CA;
  --app-chart-2: #F2A15F;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--app-text);
  background: var(--app-bg);
  overflow-x: hidden;
}
a { color: var(--app-on-primary-soft); text-decoration: none; }
a:hover { color: var(--app-primary-hover); }
h1, h2, h3, h4, h5 { margin: 0 0 .4em; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 16px; } h4 { font-size: 15px; }
p { margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--app-border); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--app-focus); outline-offset: 2px; }
::selection { background: var(--app-primary-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--app-border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- app shell ---------- */
.wrapper { min-height: 100vh; }
.app-sidebar {
  position: fixed; z-index: 40; top: 16px; bottom: 16px; left: 16px;
  width: var(--app-sidebar-w);
  display: flex; flex-direction: column;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 28px;
  box-shadow: var(--app-shadow);
  overflow: hidden;
}
.app-brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 8px; color: var(--app-text); }
.app-brand:hover { color: var(--app-text); }
.brand-logo { display: block; width: 100%; max-width: 220px; height: auto; }
.brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }
.app-brand-sub { display: flex; align-items: center; gap: 6px; margin: 0 22px 10px; padding: 6px 12px; border-radius: var(--app-radius-pill); background: var(--app-surface-muted); color: var(--app-text-muted); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.login-brand .brand-logo { max-width: 260px; }
.app-nav { flex: 1; overflow-y: auto; padding: 6px 14px 14px; }
.app-nav-label { margin: 14px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--app-text-muted); }
.app-nav a, .app-nav .nav-group > summary {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 12px; margin: 2px 0;
  border-radius: 16px;
  color: var(--app-text); font-weight: 600; font-size: 14px;
  cursor: pointer; list-style: none;
  transition: background-color .18s ease, color .18s ease;
}
.app-nav .nav-group > summary::-webkit-details-marker { display: none; }
.app-nav a > i:first-child, .app-nav summary > i:first-child {
  width: 32px; height: 32px; flex: none; border-radius: 11px;
  display: grid; place-items: center; font-size: 15px;
  background: var(--app-surface-muted); color: var(--app-text-muted);
  transition: inherit;
}
.app-nav a:hover, .app-nav summary:hover { background: var(--app-surface-muted); color: var(--app-text); }
.app-nav a.active, .app-nav .nav-group.active > summary { background: var(--app-primary-soft); color: var(--app-on-primary-soft); }
.app-nav a.active > i:first-child, .app-nav .nav-group.active > summary > i:first-child { background: var(--app-primary); color: var(--app-on-primary); }
.app-nav summary .fa-angle-down { margin-left: auto; transition: transform .2s ease; }
.app-nav details[open] > summary .fa-angle-down { transform: rotate(180deg); }
.app-nav .nav-sub { padding: 2px 0 6px 22px; margin-left: 16px; border-left: 2px solid var(--app-border); }
.app-nav .nav-sub a { min-height: 40px; font-weight: 500; font-size: 13.5px; padding: 6px 12px; }
.app-nav .nav-sub a > i:first-child { width: auto; height: auto; background: none; font-size: 14px; }
.app-nav .nav-sub a.active > i:first-child { background: none; color: inherit; }
.app-sidebar-foot { padding: 12px 16px 18px; border-top: 1px solid var(--app-border); display: grid; gap: 8px; }
.app-sidebar-foot label { font-size: 12px; color: var(--app-text-muted); font-weight: 600; }

#main { margin-left: calc(var(--app-sidebar-w) + 32px); padding: 16px 28px 32px 0; min-width: 0; }
.app-topbar {
  position: sticky; top: 12px; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 22px; margin-bottom: 20px;
  background: color-mix(in srgb, var(--app-surface) 88%, transparent);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-pill);
  box-shadow: var(--app-shadow-sm);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.app-topbar-title { flex: 1; min-width: 0; }
.app-topbar-title h1 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar-title small { color: var(--app-text-muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--app-border);
  background: var(--app-surface-raised); color: var(--app-text);
  font-size: 16px; cursor: pointer;
  transition: background-color .18s ease, transform .18s ease;
}
.icon-btn:hover { background: var(--app-primary-soft); color: var(--app-on-primary-soft); }
.icon-btn:active { transform: scale(.96); }
.theme-toggle .fa-sun-o { display: none; }
:root[data-theme="dark"] .theme-toggle .fa-sun-o { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .fa-moon-o { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: var(--app-radius-pill);
  background: var(--app-surface-muted); color: var(--app-text);
  font-weight: 600; font-size: 13px; white-space: nowrap;
}
.router-switch { max-width: 240px; min-height: 44px; border-radius: var(--app-radius-pill) !important; padding: 0 36px 0 16px !important; font-weight: 600; }
.idle-timer { color: var(--app-text-muted); }
.idle-timer #timer { font-variant-numeric: tabular-nums; }
.main-container { animation: mbx-fade .25s ease both; }
@keyframes mbx-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.app-overlay { display: none; }
.mobile-nav { display: none; }

/* ---------- cards & layout ---------- */
.row { margin: 0 -8px; }
.row::after { content: ""; display: table; clear: both; }
[class*=col-] { float: left; padding: 0 8px; min-width: 0; }
.col-1 { width: 8.33%; } .col-2 { width: 16.66%; } .col-3 { width: 25%; } .col-4 { width: 33.33%; }
.col-5 { width: 41.66%; } .col-6 { width: 50%; } .col-7 { width: 58.33%; } .col-8 { width: 66.66%; }
.col-9 { width: 75%; } .col-10 { width: 83.33%; } .col-11 { width: 91.66%; } .col-12 { width: 100%; }
.w-1 { width: 8.33%; } .w-2 { width: 16.66%; } .w-3 { width: 25%; } .w-4 { width: 33.33%; } .w-5 { width: 41.66%; } .w-6 { width: 50%; }
.w-7 { width: 58.33%; } .w-8 { width: 66.66%; } .w-9 { width: 75%; } .w-10 { width: 83.33%; } .w-11 { width: 91.66%; } .w-12 { width: 100%; }

.card {
  margin: 0 0 16px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-card);
  box-shadow: var(--app-shadow);
  min-width: 0;
}
.card .card { box-shadow: none; background: var(--app-surface-raised); border-radius: 20px; }
.card-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 18px 22px 10px;
}
.card-header h3, .card-title { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card-header h3 > i:first-child, .card-title > i:first-child {
  width: 34px; height: 34px; border-radius: 12px; display: inline-grid; place-items: center;
  background: var(--app-primary-soft); color: var(--app-on-primary-soft); font-size: 15px;
}
.card-body { padding: 10px 22px 20px; overflow-x: auto; }
.card-footer { padding: 0 22px 18px; }
.card a { text-decoration: none; }
.overflow { overflow: auto; max-height: 72vh; border-radius: 16px; border: 1px solid var(--app-border); }

/* soft tinted boxes (dashboard KPIs, router tiles, alerts) */
.box {
  --tone: var(--tone-grey);
  position: relative;
  margin: 0 0 16px; padding: 16px;
  border-radius: 20px;
  background: var(--app-surface-raised);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  transition: transform .18s ease, box-shadow .18s ease;
}
.box a { color: inherit; display: block; }
.box h1 { font-size: 30px; margin: 0 0 6px; font-weight: 800; letter-spacing: -.02em; }
.box h1 span { font-size: 12px !important; font-weight: 600; color: var(--app-text-muted); margin-left: 4px; }
.box-bordered { border: 1px solid var(--app-border); }
.box[class*=bg-] {
  background: color-mix(in srgb, var(--tone) var(--app-tint), var(--app-surface));
  border-color: color-mix(in srgb, var(--tone) 22%, transparent);
  color: var(--app-text);
}
.box[class*=bg-] a { color: var(--app-text); }
a > .box:hover, .box:has(> a):hover { transform: translateY(-2px); box-shadow: var(--app-shadow-sm); }
.box-group { display: flex; align-items: center; gap: 14px; }
.box-group > div { display: block; }
.box-group-icon {
  width: 48px; height: 48px; flex: none; margin: 0;
  display: grid; place-items: center;
  border-radius: 16px; font-size: 20px;
  background: color-mix(in srgb, var(--tone) 85%, #000 0%); color: #fff;
}
.box:not([class*=bg-]) .box-group-icon { background: var(--app-primary-soft); color: var(--app-on-primary-soft); }
.box-group-icon a, .box-group-icon span { color: inherit !important; display: grid; place-items: center; width: 100%; height: 100%; }
.box-group-area { min-width: 0; padding: 0; color: var(--app-text); line-height: 1.6; overflow-wrap: anywhere; }
.box-group-area a { display: inline; color: var(--app-on-primary-soft) !important; font-weight: 600; }
.bmh-50 { min-height: 50px; } .bmh-55 { min-height: 55px; } .bmh-60 { min-height: 60px; } .bmh-65 { min-height: 65px; }
.bmh-70 { min-height: 70px; } .bmh-75 { min-height: 75px; } .bmh-80 { min-height: 80px; } .bmh-85 { min-height: 85px; }
.bmh-90 { min-height: 90px; } .bmh-95 { min-height: 95px; } .bmh-100 { min-height: 100px; }

/* ---------- color tones ---------- */
.bg-primary { --tone: var(--app-primary); }
.bg-secondary, .bg-grey, .bg-grey-dark { --tone: var(--tone-grey); }
.bg-success, .bg-green { --tone: var(--tone-green); }
.bg-info, .bg-light-blue { --tone: var(--tone-sky); }
.bg-warning, .bg-yellow { --tone: var(--tone-yellow); }
.bg-danger, .bg-red { --tone: var(--tone-red); }
.bg-blue { --tone: var(--tone-blue); }
.bg-indigo { --tone: var(--tone-indigo); }
.bg-purple { --tone: var(--tone-purple); }
.bg-pink { --tone: var(--tone-pink); }
.bg-orange { --tone: var(--tone-orange); }
.bg-teal { --tone: var(--tone-teal); }
.bg-cyan { --tone: var(--tone-cyan); }
.bg-dark { --tone: var(--tone-dark); }
[class*=bg-]:not(.box):not(.btn):not(input):not(button) {
  background: color-mix(in srgb, var(--tone) var(--app-tint), var(--app-surface));
  color: color-mix(in srgb, var(--tone) 70%, var(--app-text));
}
div[class*=bg-]:not(.box):not(.btn) { border-radius: 14px; padding: 10px 14px; }
.bg-light, .bg-white { background: var(--app-surface-raised) !important; color: var(--app-text) !important; }

.text-primary, .text-orange { color: var(--app-on-primary-soft) !important; }
.text-success, .text-green, .text-teal { color: var(--app-success) !important; }
.text-warning, .text-yellow { color: var(--app-warning) !important; }
.text-danger, .text-red, .text-pink { color: var(--app-danger) !important; }
.text-info, .text-blue, .text-cyan, .text-light-blue, .text-indigo, .text-purple { color: color-mix(in srgb, var(--tone-blue) 75%, var(--app-text)) !important; }
.text-secondary, .text-grey { color: var(--app-text-muted) !important; }
.text-dark, .text-grey-dark { color: var(--app-text) !important; }
.text-light, .text-white { color: #fff; }
.cl-w { color: var(--app-text); }
.text-center { text-align: center; } .text-right { text-align: right; } .text-left { text-align: left; }
.text-nowrap { white-space: nowrap; } .text-bold { font-weight: 700; }
.align-middle { vertical-align: middle; }
.pointer { cursor: pointer; }

/* ---------- buttons ---------- */
.btn, button.btn, a.btn, input.btn, .btn-login {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; margin: 4px 4px 4px 0;
  border-radius: var(--app-radius-pill);
  border: 1px solid var(--app-border);
  background: var(--app-surface-raised); color: var(--app-text);
  font: inherit; font-weight: 600; font-size: 13.5px;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.btn:hover { background: var(--app-surface-muted); color: var(--app-text); }
.btn:active, .btn-login:active { transform: scale(.98); }
.btn[class*=bg-] {
  background: color-mix(in srgb, var(--tone) var(--app-tint), var(--app-surface));
  border-color: transparent;
  color: color-mix(in srgb, var(--tone) 72%, var(--app-text));
}
.btn.bg-primary, input.bg-primary, button.bg-primary, .btn-login, input[type=submit].group-item, .group-item.bg-primary {
  background: var(--app-primary); color: var(--app-on-primary); border-color: transparent;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--app-primary) 28%, transparent);
}
.btn.bg-primary:hover, input.bg-primary:hover, button.bg-primary:hover, .btn-login:hover, input[type=submit].group-item:hover {
  background: var(--app-primary-hover); color: var(--app-on-primary);
}
.btn-mrg { margin: 4px; }
button { font: inherit; }
button:disabled, .btn:disabled, input:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- forms ---------- */
label { font-weight: 600; font-size: 13px; }
.form-control, .group-item, select.ses {
  display: block; width: 100%;
  min-height: 44px; padding: 10px 14px;
  font: inherit; font-size: 14px;
  color: var(--app-text);
  background: var(--app-surface-raised);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-control);
  transition: border-color .18s ease, box-shadow .18s ease;
}
select.form-control, select.group-item, select.ses {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--app-text-muted) 50%), linear-gradient(135deg, var(--app-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
textarea.form-control { min-height: 96px; }
.form-control:focus, .group-item:focus, select.ses:focus { outline: 0; border-color: var(--app-primary); box-shadow: 0 0 0 4px var(--app-focus); }
.form-control::placeholder, .group-item::placeholder { color: var(--app-text-muted); opacity: .8; }
input[type=checkbox], input[type=radio] { accent-color: var(--app-primary); width: 16px; height: 16px; vertical-align: middle; }
.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group::after { content: ""; display: table; clear: both; }
[class*=input-group-] { float: left; min-width: 0; }
.input-group > [class*=input-group-] { float: none; }
.input-group > [class*=col-] { padding: 0; }
.input-group > [class*=input-group-]:last-child:not(:first-child) { flex: 1 0 auto; min-width: 44px; }
.input-group-1 { width: 8.33%; } .input-group-2 { width: 16.66%; } .input-group-3 { width: 25%; } .input-group-4 { width: 33.33%; }
.input-group-5 { width: 41.66%; } .input-group-6 { width: 50%; } .input-group-7 { width: 58.33%; } .input-group-8 { width: 66.66%; }
.input-group-9 { width: 75%; } .input-group-10 { width: 83.33%; } .input-group-11 { width: 91.66%; } .input-group-12 { width: 100%; }
.input-group .group-item { height: 100%; }
.group-item-l { border-radius: var(--app-radius-control) 0 0 var(--app-radius-control); }
.group-item-r { border-radius: 0 var(--app-radius-control) var(--app-radius-control) 0; margin-left: -1px; display: flex; align-items: center; justify-content: center; }
.group-item-m, .group-item-md { border-radius: 0; margin-left: -1px; }
div.group-item { display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--app-surface-muted); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: separate !important; border-spacing: 0; background: transparent; font-size: 13.5px; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; color: var(--app-text); border: 0 !important; border-bottom: 1px solid var(--app-border) !important; }
.table thead th, .table > tr:first-child > th, .thead-light th {
  position: sticky; top: 0; z-index: 1;
  background: var(--app-surface-muted); color: var(--app-text-muted);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  cursor: pointer; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0 !important; }
.table-hover tbody tr { transition: background-color .15s ease; }
.table-hover tbody tr:hover { background: color-mix(in srgb, var(--app-primary) 6%, transparent); }
.table-sm th, .table-sm td { padding: 8px 10px; }
.card-body > .table:not(.table-sm), .card-body > form > .table:not(.table-sm) { border: 1px solid var(--app-border); border-radius: 16px; overflow: hidden; }
.table td a { color: var(--app-on-primary-soft); font-weight: 600; }
.table td i.fa { margin-right: 2px; }
.tscroll tbody { display: block; overflow: auto; height: 70vh; }
.tscroll thead { position: relative; display: block; }

/* ---------- progress, modal, notify, loader ---------- */
.progress { width: 100%; height: 10px; background: var(--app-surface-muted); border-radius: var(--app-radius-pill); overflow: hidden; }
.progress-bar, .progress-bar-blue, .progress-bar-red { height: 10px; max-width: 100%; border-radius: var(--app-radius-pill); background: var(--app-primary); }
.progress-bar-red { background: var(--tone-red); }
.modal-window {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(15, 17, 20, .45);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.modal-window:target { opacity: 1; pointer-events: auto; }
.modal-window > div {
  position: relative; width: min(520px, calc(100vw - 32px)); margin: 10vh auto; padding: 24px;
  background: var(--app-surface); color: var(--app-text);
  border-radius: var(--app-radius-card); border: 1px solid var(--app-border); box-shadow: var(--app-shadow);
}
.modal-window h1 { font-size: 20px; margin: 0 0 14px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--app-surface-muted); color: var(--app-text) !important; font-size: 13px;
}
#notify {
  display: none; position: fixed; z-index: 1000; top: 20px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: var(--app-radius-pill);
  background: var(--app-text); color: var(--app-bg); font-weight: 600; box-shadow: var(--app-shadow);
}
#temp { display: none; }
.lds-dual-ring { display: block; width: 48px; height: 48px; margin: 18vh auto; }
.lds-dual-ring::after {
  content: ""; display: block; width: 40px; height: 40px; margin: 4px; border-radius: 50%;
  border: 4px solid var(--app-primary); border-color: var(--app-primary) transparent; animation: mbx-spin 1s linear infinite;
}
@keyframes mbx-spin { to { transform: rotate(360deg); } }
.chart { height: 200px; margin: 0 auto; }
#trafficMonitor, .highcharts-container { border-radius: 16px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--app-primary) 16%, transparent), transparent 60%),
  radial-gradient(700px 400px at 110% 110%, color-mix(in srgb, var(--tone-sky) 12%, transparent), transparent 60%),
  var(--app-bg); }
.login-card { width: min(420px, 100%); padding: 32px 28px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 28px; box-shadow: var(--app-shadow); }
.login-card .app-brand { padding: 0 56px 22px 0; }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--app-text-muted); margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field label { display: block; margin-bottom: 6px; }
.login-card .btn-login { width: 100%; min-height: 48px; margin: 8px 0 0; font-size: 15px; }
.login-card .theme-toggle { position: absolute; top: 20px; right: 20px; }
.alert-error { margin-top: 14px; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--tone-red) var(--app-tint), var(--app-surface)); color: var(--app-danger); font-weight: 600; }
.pwa-install { margin-top: 18px; }
.pwa-divider { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; color: var(--app-text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.pwa-divider::before, .pwa-divider::after { content: ""; flex: 1; border-top: 1px solid var(--app-border); }
.btn.pwa-install-btn { width: 100%; min-height: 48px; margin: 0; background: var(--app-primary-soft); color: var(--app-on-primary-soft); border-color: transparent; }
.btn.pwa-install-btn:hover { background: color-mix(in srgb, var(--app-primary) 22%, var(--app-surface)); color: var(--app-on-primary-soft); }
.pwa-hint { margin: 12px 0 0 !important; padding: 10px 14px; border-radius: 14px; background: var(--app-surface-muted); color: var(--app-text) !important; font-size: 13px; }
.login-box, .register-box { width: min(420px, 100%); margin: 10vh auto 0; }
.settings { width: min(66.66%, 100%); margin: 5% auto 0; }

/* ---------- spacing utilities (legacy) ---------- */
.pd-2 { padding: 2px; } .pd-2p5 { padding: 2.5px; } .pd-3 { padding: 3px; } .pd-3p5 { padding: 3.5px; } .pd-5 { padding: 5px; } .pd-10 { padding: 10px; }
.pd-t-5 { padding-top: 5px; } .pd-b-5 { padding-bottom: 5px; } .pd-t-10 { padding-top: 10px; } .pd-b-10 { padding-bottom: 10px; }
.mr-a { margin: auto; } .mr-1 { margin-right: 4px; } .mr-2 { margin: 2px; } .mr-5 { margin: 5px; } .mr-10 { margin: 10px; }
.mr-t-5 { margin-top: 5px; } .mr-t-10 { margin-top: 10px; } .mr-b-5 { margin-bottom: 5px; } .mr-b-10 { margin-bottom: 10px; }
.mr-l-5 { margin-left: 5px; } .mr-r-5 { margin-right: 5px; }
.radius-3, .radius-5 { border-radius: 10px; }
.alert { width: 100%; padding: 10px 14px; border-radius: 14px; }

/* ---------- CodeMirror (voucher editor) ---------- */
.CodeMirror { border-radius: 16px; }
.cm-s-material.CodeMirror { background-color: #1E2228; color: #E9EDED; }
.cm-s-material .CodeMirror-gutters { background: #1E2228; color: #6B7F86; border: none; }
.cm-s-material .CodeMirror-linenumber { color: #6B7F86; }
.cm-s-material .CodeMirror-cursor { border-left: 1px solid #F8F8F0; }
.cm-s-material div.CodeMirror-selected { background: rgba(255, 255, 255, .15); }
.cm-s-material .cm-keyword { color: #C792EA; } .cm-s-material .cm-operator { color: #E9EDED; }
.cm-s-material .cm-variable-2 { color: #80CBC4; } .cm-s-material .cm-builtin { color: #DECB6B; }
.cm-s-material .cm-atom, .cm-s-material .cm-number { color: #F77669; } .cm-s-material .cm-string { color: #C3E88D; }
.cm-s-material .cm-comment { color: #546E7A; } .cm-s-material .cm-variable { color: #82B1FF; }
.cm-s-material .cm-meta { color: #80CBC4; } .cm-s-material .cm-attribute { color: #FFCB6B; }
.cm-s-material .cm-property { color: #80CBAE; } .cm-s-material .cm-tag { color: #FF5370; }
.cm-s-material .cm-error { color: #fff; background-color: #EC5F67; }
.cm-s-material .CodeMirror-matchingbracket { text-decoration: underline; color: #fff !important; }

/* ---------- tablet ---------- */
@media (max-width: 1279px) {
  :root { --app-sidebar-w: 240px; }
  #main { padding-right: 20px; }
}

/* ---------- mobile & tablet: drawer sidebar + floating bottom-right nav ---------- */
@media (max-width: 1023px) {
  .app-sidebar {
    top: 0; bottom: 0; left: 0; border-radius: 0 28px 28px 0;
    width: min(300px, 86vw);
    transform: translateX(-105%); transition: transform .25s ease;
  }
  body.nav-open .app-sidebar { transform: none; }
  body.nav-open .app-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 17, 20, .4); }
  #main { margin-left: 0; padding: 12px 16px calc(120px + env(safe-area-inset-bottom)); }
  .app-topbar { top: 8px; padding: 8px 8px 8px 16px; margin-bottom: 16px; }
  .app-topbar-title h1 { font-size: 17px; }

  .mobile-nav {
    position: fixed; z-index: 50;
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 4px;
    width: max-content;
    max-width: calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right));
    padding: 7px;
    border-radius: var(--app-radius-pill);
    background: color-mix(in srgb, var(--app-surface) 90%, transparent);
    border: 1px solid var(--app-border);
    box-shadow: var(--app-shadow);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  }
  .mobile-nav a, .mobile-nav button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 46px; min-height: 46px; padding: 0 12px;
    border: 0; border-radius: var(--app-radius-pill);
    background: transparent; color: var(--app-text-muted);
    font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
  }
  .mobile-nav i { font-size: 18px; }
  .mobile-nav .label { display: none; }
  .mobile-nav [aria-current="page"] { background: var(--app-primary); color: var(--app-on-primary); }
  .mobile-nav [aria-current="page"] .label { display: inline; }
  body.nav-open .mobile-nav { display: none; }
}
@media (max-width: 767px) {
  body { font-size: 14px; }
  [class*=col-] { width: 100%; }
  .col-box-1 { width: 8.33%; } .col-box-2 { width: 16.66%; } .col-box-3 { width: 25%; } .col-box-4 { width: 33.33%; }
  .col-box-5 { width: 41.66%; } .col-box-6 { width: 50%; } .col-box-7 { width: 58.33%; } .col-box-8 { width: 66.66%; }
  .col-box-9 { width: 75%; } .col-box-10 { width: 83.33%; } .col-box-11 { width: 91.66%; } .col-box-12 { width: 100%; }
  .card { border-radius: 22px; }
  .card-header { padding: 16px 16px 8px; }
  .card-body { padding: 8px 16px 16px; }
  .box h1 { font-size: 26px; }
  .app-topbar-actions .hide-sm { display: none; }
  .router-switch { max-width: 140px; }
  .settings { width: 100%; }
  .table th, .table td { padding: 10px 12px; }
}
@media (max-width: 380px) {
  .mobile-nav a, .mobile-nav button { min-width: 44px; padding: 0 10px; }
  .router-switch { max-width: 112px; }
}

/* ---------- print ---------- */
@media print {
  .app-sidebar, .app-topbar, .mobile-nav, .app-overlay { display: none !important; }
  #main { margin: 0; padding: 0; }
  .card { box-shadow: none; }
}
