@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f8fa;
  --panel: #ffffff;
  --sidebar: #073845;
  --sidebar-2: #062f3a;
  --accent: #087f8c;
  --accent-2: #0b7280;
  --ink: #132b33;
  --muted: #71848d;
  --line: #dde7eb;
  --soft: #f8fbfc;
  --success: #15945b;
  --danger: #c0342b;
  --warning: #b7791f;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(14, 45, 55, 0.07);
  --shadow-strong: 0 22px 55px rgba(6, 47, 58, .14);
  --font: "Vazirmatn", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 14px;
  letter-spacing: 0;
}
body.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 16%, rgba(8, 127, 140, .16), transparent 30%),
    linear-gradient(135deg, #eef7f8 0%, #ffffff 50%, #e9f5f2 100%);
}
a { color: inherit; text-decoration: none; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fillBar {
  from { width: 0; }
}
@keyframes pulseSoft {
  0%,100% { transform: scale(1); opacity: .75; }
  50% { transform: scale(1.05); opacity: 1; }
}

.auth-shell {
  width: min(1180px, calc(100vw - 48px));
  min-height: min(720px, calc(100vh - 64px));
  display: grid;
  grid-template-columns: minmax(380px, 430px) minmax(0, 1fr);
  align-items: stretch;
  padding: 0;
  direction: ltr;
  border-radius: 18px;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}
.auth-visual {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(34px, 5vw, 64px);
  overflow: hidden;
  border: 1px solid rgba(8,127,140,.14);
  border-right: 0;
  border-radius: 0 18px 18px 0;
  background:
    linear-gradient(rgba(7,56,69,.84), rgba(7,56,69,.9)),
    radial-gradient(circle at 30% 30%, rgba(26,181,141,.35), transparent 34%),
    linear-gradient(135deg, #073845, #062f3a);
  color: #fff;
  box-shadow: none;
  direction: rtl;
}
.auth-brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 26px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 14px;
  background: rgba(255,255,255,.1);
  font-size: 25px;
  font-weight: 950;
}
.auth-visual h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.18;
  font-weight: 950;
}
.auth-visual p {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(255,255,255,.74);
  font-size: 16px;
}
.auth-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 740px;
  margin-top: 34px;
}
.auth-metrics span {
  min-height: 92px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
}
.auth-metrics b,
.auth-metrics small { display: block; }
.auth-metrics small {
  margin-top: 6px;
  color: rgba(255,255,255,.64);
}
.auth-card {
  align-self: stretch;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 18px 0 0 18px;
  box-shadow: none;
  padding: clamp(34px, 4vw, 52px);
  direction: rtl;
}
.auth-kicker {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}
.auth-card h1 { margin: 0 0 8px; font-size: 28px; font-weight: 850; }
.auth-card p, .seed { color: var(--muted); }
.auth-switch {
  margin-top: 20px;
  text-align: center;
}
.auth-switch a {
  color: var(--accent);
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
}
.sidebar {
  grid-column: 2;
  grid-row: 1;
  min-height: 100vh;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #eaf6f7;
  padding: 26px 16px;
  box-shadow: -10px 0 28px rgba(7, 56, 69, 0.08);
}
.main {
  grid-column: 1;
  grid-row: 1;
  padding: 30px;
  min-width: 0;
}
.brand {
  min-height: 72px;
  display: flex;
  align-items: center;
  padding: 0 12px 22px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  font-size: 21px;
  font-weight: 900;
}
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a, .logout {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 16px;
  border-radius: var(--radius);
  color: #d6e9ec;
  font-weight: 750;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active {
  background: linear-gradient(180deg, #1195a4, #087783);
  color: #fff;
  box-shadow: 0 10px 22px rgba(2, 101, 113, .25);
}
.logout {
  position: absolute;
  right: 16px;
  left: 16px;
  bottom: 22px;
  border-top: 1px solid rgba(255,255,255,.12);
  color: #d7ecee;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 24px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.topbar span { color: var(--muted); font-size: 13px; }
.topbar h1 { margin: 2px 0 0; font-size: 26px; font-weight: 850; }
.topbar strong {
  min-width: 170px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--accent);
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 850;
}

.grid { display: grid; gap: 18px; }
.cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 24px 0 20px;
}
.stat {
  min-height: 132px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: riseIn .45s ease both;
}
.stat span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.stat strong { display: block; color: #102f39; font-size: 28px; font-weight: 900; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
  animation: riseIn .5s ease both;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 14px; font-size: 18px; font-weight: 850; }
.panel-head h2 { margin: 0; }

.split { display: grid; grid-template-columns: 380px minmax(0,1fr); gap: 20px; align-items: start; }
.plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 24px; }
.plan p { color: var(--muted); margin: 0 0 8px; }
.plan strong { display: block; color: var(--accent); font-size: 24px; margin: 12px 0 18px; }
.admin-menu { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; margin-top: 20px; }
.admin-tile {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 850;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.admin-tile:hover {
  transform: translateY(-3px);
  border-color: #b7dce2;
  box-shadow: var(--shadow-strong);
}

form { display: grid; gap: 13px; }
label {
  display: grid;
  gap: 7px;
  color: #29424a;
  font-weight: 750;
  font-size: 13px;
  position: relative;
}
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, .11);
  background: #fff;
}
.password-toggle {
  position: absolute;
  left: 10px;
  top: 35px;
  z-index: 1;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.inline-form, .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, border-color .18s, background .18s;
}
.btn:hover { border-color: #bfd1d6; box-shadow: 0 8px 18px rgba(13, 50, 60, .07); }
.btn.primary {
  background: linear-gradient(180deg, #0b8e9b, #087783);
  border-color: #087783;
  color: #fff;
  box-shadow: 0 10px 20px rgba(8, 127, 140, .18);
}
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn.danger { background: #fff5f4; border-color: #ffd5d1; color: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius);
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}
th {
  background: #f8fbfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
tr:hover td { background: #fbfdfe; }
.status, .status-badge, .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 850;
  background: #edf6f7;
  color: var(--accent);
}
.status.active, .status-badge.active, .badge.open { background: #e8f8ef; color: var(--success); }
.status.expired, .status-badge.expired { background: #fff1f0; color: var(--danger); }
.status.pending, .badge.waiting_admin { background: #fff8e8; color: var(--warning); }

.flash {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 16px 0;
  font-weight: 750;
  border: 1px solid transparent;
}
.flash.success { background: #eaf8ef; color: #126b42; border-color: #c9ecd6; }
.flash.error { background: #fff1f0; color: var(--danger); border-color: #ffd5d1; }
.empty, .hint { color: var(--muted); }

.messages {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.msg {
  max-width: 78%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.msg.admin { margin-right: auto; background: #eaf7f8; border-color: #c7e7eb; }
.msg p { margin: 4px 0 0; white-space: pre-wrap; }

.service-header, .ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.config-section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.config-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.config-title-row h3 { margin: 0; }
.config-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 14px;
  margin-bottom: 12px;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(7, 56, 69, .55);
  backdrop-filter: blur(10px);
}
.modal-content {
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-strong);
  padding: 24px;
  text-align: center;
}
#qrcode {
  display: grid;
  place-items: center;
  min-height: 280px;
  margin-top: 14px;
  border: 1px dashed #c8dade;
  border-radius: 12px;
  background: var(--soft);
}
.qr-fallback {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  direction: ltr;
  text-align: left;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.service-control-panel {
  border-color: #d8e8ec;
  background: linear-gradient(180deg, #fff, #f8fcfd);
}
.service-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.user-ticket-form {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: min(100%, 320px);
}
.user-ticket-form input {
  min-height: 36px;
  font-size: 12px;
}

.dash-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  align-items: center;
  gap: 22px;
  margin: 24px 0 20px;
  padding: 26px;
  overflow: hidden;
  border: 1px solid #bddbe1;
  border-radius: 12px;
  background:
    radial-gradient(circle at 14% 20%, rgba(12, 145, 158, .16), transparent 30%),
    linear-gradient(135deg, #ffffff 0%, #edf8fa 58%, #e5f4f6 100%);
  box-shadow: var(--shadow-strong);
  animation: riseIn .35s ease both;
}
.dash-hero::after {
  content: "";
  position: absolute;
  inset: auto -90px -120px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(8, 127, 140, .13);
  filter: blur(2px);
}
.admin-hero {
  background:
    radial-gradient(circle at 18% 20%, rgba(21, 148, 91, .13), transparent 32%),
    linear-gradient(135deg, #ffffff 0%, #edf8f5 60%, #e7f5f1 100%);
}
.eyebrow {
  display: inline-flex;
  color: var(--accent);
  font-weight: 850;
  font-size: 12px;
  margin-bottom: 8px;
}
.dash-hero h2 {
  margin: 0;
  max-width: 760px;
  font-size: 28px;
  line-height: 1.45;
  font-weight: 900;
  color: #0d3038;
}
.dash-hero p {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
}
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.donut-card {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(8,127,140,.16);
  border-radius: 12px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(8px);
}
.donut-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.donut {
  --value: 0;
  width: 126px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), #dfecef 0);
  box-shadow: inset 0 0 0 12px rgba(255,255,255,.7);
}
.donut::before {
  content: "";
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}
.donut b {
  position: relative;
  z-index: 1;
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
}
.smart-stat {
  position: relative;
  overflow: hidden;
  min-height: 150px;
}
.smart-stat::after {
  content: "";
  position: absolute;
  left: -46px;
  bottom: -60px;
  width: 135px;
  height: 135px;
  border-radius: 50%;
  background: rgba(8,127,140,.06);
}
.stat-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 10px;
  color: var(--accent);
  background: #e8f6f8;
}
.stat-icon svg { width: 23px; height: 23px; }
.smart-stat em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 20px;
}
.span-2 { grid-column: span 1; }
.span-3 { grid-column: 1 / -1; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef8fa;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(130px, 2fr) 42px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.bar-row:last-child { border-bottom: 0; }
.bar-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #24414a;
  font-weight: 750;
}
.bar-row b {
  color: var(--accent);
  font-size: 12px;
  text-align: left;
}
.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8f0f2;
}
.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0a8b98, #1ab58d);
  animation: fillBar .9s ease both;
}
.timeline {
  display: grid;
  gap: 14px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 14px minmax(0,1fr);
  gap: 12px;
  align-items: start;
}
.timeline-item .dot {
  width: 11px;
  height: 11px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(8,127,140,.1);
  animation: pulseSoft 2.4s ease infinite;
}
.timeline-item .dot.rejected { background: var(--danger); box-shadow: 0 0 0 5px rgba(192,52,43,.1); }
.timeline-item .dot.approved { background: var(--success); box-shadow: 0 0 0 5px rgba(21,148,91,.1); }
.timeline-item strong { display: block; font-weight: 850; }
.timeline-item small { color: var(--muted); }
.launch-list {
  display: grid;
  gap: 10px;
}
.launch-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.launch-item span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 950;
}
.launch-item.ok span { background: #e8f8ef; color: var(--success); }
.launch-item.todo span { background: #fff8e8; color: var(--warning); }
.launch-item strong { font-size: 13px; }
.launch-item small { color: var(--muted); font-weight: 750; }
.cell-progress {
  min-width: 170px;
  display: grid;
  gap: 6px;
}
.cell-progress span {
  color: #29424a;
  font-size: 12px;
}
.cell-progress i {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0a8b98, #1ab58d);
  box-shadow: inset 0 0 0 999px rgba(255,255,255,.0);
  animation: fillBar .8s ease both;
}
.cell-progress::after {
  content: "";
  height: 6px;
  margin-top: -12px;
  border-radius: 999px;
  background: #e8f0f2;
  z-index: -1;
}

.upload-label {
  gap: 9px;
}
.upload-card {
  position: relative;
  min-height: 116px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1.5px dashed #b8d0d6;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfefe, #f4fafb);
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .18s;
}
.upload-card:hover,
.upload-card:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 10px 24px rgba(8, 127, 140, .10);
}
.upload-card.has-file {
  border-style: solid;
  border-color: #91d6bd;
  background: #f3fbf7;
}
.upload-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #e7f5f7;
  color: var(--accent);
}
.upload-card.has-file .upload-mark {
  background: #dff7ea;
  color: var(--success);
}
.upload-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.upload-copy strong {
  font-size: 14px;
  color: var(--ink);
}
.upload-copy small {
  color: var(--muted);
  font-weight: 500;
}
.upload-copy em {
  margin-top: 7px;
  color: var(--accent);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-card input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.msg-attachment {
  margin-top: 10px;
}
.msg-attachment img {
  max-width: min(280px, 100%);
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

@media (max-width: 1100px) {
  .cards, .plan-grid, .admin-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .dashboard-grid, .dash-hero { grid-template-columns: 1fr; }
  .donut-card { justify-self: start; }
  .auth-shell {
    width: min(680px, calc(100vw - 32px));
    min-height: auto;
    grid-template-columns: 1fr;
    margin: 18px auto;
  }
  .auth-visual {
    min-height: auto;
    border-radius: 18px 18px 0 0;
    border: 1px solid rgba(8,127,140,.14);
    border-bottom: 0;
    padding: 34px;
  }
  .auth-card {
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 18px 18px;
  }
  .auth-metrics { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  body.auth { display: block; }
  .auth-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  .auth-visual,
  .auth-card { border-radius: 0; }
  .auth-visual { padding: 28px 22px; }
  .auth-card { padding: 30px 22px; }
  .app-shell { display: block; min-height: 100vh; }
  .sidebar {
    position: static;
    min-height: auto;
    padding: 14px;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 10px 24px rgba(7, 56, 69, .14);
  }
  .brand {
    min-height: 46px;
    padding: 0 6px 10px;
    margin-bottom: 10px;
    font-size: 18px;
  }
  .sidebar nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .sidebar nav a,
  .logout {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 12px;
    white-space: nowrap;
    font-size: 13px;
  }
  .logout {
    position: static;
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,.12);
    justify-content: center;
  }
  .main { padding: 14px; }
  .topbar {
    min-height: auto;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 2px;
  }
  .topbar h1 { font-size: 21px; line-height: 1.35; }
  .topbar span { font-size: 12px; }
  .topbar strong {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    font-size: 15px;
  }
  .cards, .stat-grid, .plan-grid, .admin-menu {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .cards { margin: 14px 0; }
  .stat, .smart-stat {
    min-height: auto;
    padding: 16px;
  }
  .stat strong { font-size: 23px; }
  .panel {
    padding: 16px;
    margin-bottom: 14px;
    border-radius: 10px;
  }
  .panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  .panel-head .actions,
  .panel-head form { width: 100%; }
  .dash-hero {
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 14px 0;
    padding: 18px;
    border-radius: 10px;
  }
  .dash-hero::after {
    width: 160px;
    height: 160px;
    inset: auto -70px -80px auto;
  }
  .dash-hero h2 {
    font-size: 21px;
    line-height: 1.5;
  }
  .dash-hero p { font-size: 13px; }
  .hero-actions,
  .inline-form,
  .actions {
    width: 100%;
  }
  .hero-actions .btn,
  .inline-form .btn,
  .actions .btn {
    flex: 1 1 auto;
  }
  .donut-card {
    width: 100%;
    grid-template-columns: auto 1fr;
    justify-items: start;
  }
  .donut {
    width: 86px;
    box-shadow: inset 0 0 0 9px rgba(255,255,255,.7);
  }
  .donut::before { width: 54px; height: 54px; }
  .donut b { font-size: 18px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
  .admin-tile { min-height: 68px; font-size: 15px; }
  .split { grid-template-columns: 1fr; gap: 14px; }
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
  }
  th, td {
    padding: 10px 9px;
    font-size: 12px;
  }
  .service-header,
  .ticket-header,
  .config-title-row {
    align-items: stretch;
    flex-direction: column;
  }
  .details-grid,
  .usage-grid {
    grid-template-columns: 1fr !important;
  }
  .messages { padding: 10px; }
  .msg { max-width: 100%; }
  .modal { padding: 12px; }
  .modal-content { padding: 18px; }
  .service-actions-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
  .btn { width: 100%; }
  .config-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  .config-head > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  body { font-size: 13px; }
  .main { padding: 10px; }
  .sidebar { padding: 12px 10px; }
  .panel { padding: 13px; }
  .dash-hero { padding: 15px; }
  .dash-hero h2 { font-size: 18px; }
  .topbar h1 { font-size: 19px; }
  .topbar strong { font-size: 14px; }
  .stat-grid { margin: 12px 0; }
  .smart-stat em,
  .stat span,
  .hint { font-size: 12px; }
  .bar-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .bar-track { width: 100%; }
  .user-card,
  .service-control-panel,
  .config-item {
    padding: 12px;
  }
  .user-info,
  .user-stats,
  .user-actions,
  .user-ticket-form {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .upload-card {
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 12px;
  }
  .upload-mark {
    width: 44px;
    height: 44px;
  }
  #qrcode { min-height: 230px; }
}
