:root {
  --brand: #425982;
  --brand-bright: #2f75ff;
  --brand-hover: #2563eb;
  --brand-soft: #eef3ff;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;
  --text: #111827;
  --text-2: #374151;
  --muted: #77808f;
  --line: #e5e8ee;
  --line-strong: #d9dee7;
  --danger: #c9362b;
  --danger-soft: #fff2f0;
  --success: #147a4a;
  --success-soft: #eaf8f0;
  --warning: #9a6700;
  --primary: #171a20;
  --primary-text: #ffffff;
  --tooltip: #111827;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .045);
  --shadow-md: 0 10px 30px rgba(16, 24, 40, .09);
  --shadow-lg: 0 28px 80px rgba(16, 24, 40, .14);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0d1016;
  --surface: #141922;
  --surface-2: #191f2a;
  --surface-3: #202734;
  --text: #f6f8fb;
  --text-2: #d8dee8;
  --muted: #9aa4b3;
  --line: #28313e;
  --line-strong: #344052;
  --brand: #6f8fc9;
  --brand-bright: #5d94ff;
  --brand-hover: #77a7ff;
  --brand-soft: #1d2a42;
  --danger: #ff7a70;
  --danger-soft: #321e20;
  --success: #55d391;
  --success-soft: #153023;
  --warning: #f7c65f;
  --primary: #f4f7fb;
  --primary-text: #11151c;
  --tooltip: #f4f7fb;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .18);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .18), 0 12px 32px rgba(0, 0, 0, .16);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, .24);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, .34);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, color-mix(in srgb, var(--brand-bright) 8%, transparent), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.ui-icon { width: 18px; height: 18px; display: block; flex: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.tabular-number { font-variant-numeric: tabular-nums; }

/* Sidebar */
.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 252px;
  height: 100vh;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  z-index: 30;
}

.brand {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 9px;
  margin-bottom: 20px;
  text-decoration: none;
  border-radius: 13px;
  transition: background-color .18s var(--ease), transform .18s var(--ease);
}
.brand:hover { background: var(--surface-2); transform: translateY(-1px); }
.brand-mark-wrap {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand-bright) 12%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand-bright) 16%, var(--line));
  box-shadow: var(--shadow-xs);
}
.brand img { width: 28px; height: 28px; object-fit: contain; display: block; }
.brand-wordmark { display: flex; align-items: baseline; gap: 4px; font-size: 18px; font-weight: 650; letter-spacing: -.025em; white-space: nowrap; }
.brand-wordmark strong { font-weight: 760; color: var(--brand-bright); }

nav { display: flex; flex: 1; flex-direction: column; gap: 5px; width: 100%; min-height: 0; }
.nav-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 11px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: color .18s var(--ease), background-color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.nav-link .ui-icon { width: 19px; height: 19px; stroke-width: 1.9; }
.nav-link:hover { color: var(--text); background: var(--surface-3); transform: translateX(2px); }
.nav-link.active { color: var(--text); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand-bright) 15%, var(--line)); box-shadow: inset 3px 0 0 var(--brand-bright); }
.nav-link.active .ui-icon { color: var(--brand-bright); }
.nav-logout { margin-top: auto; border-top: 1px solid var(--line); border-radius: 0 0 11px 11px; padding-top: 10px; min-height: 54px; }

.theme-sidebar { padding: 14px 8px 0; margin-top: 12px; border-top: 1px solid var(--line); }
.theme-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.theme-row .theme-label { display: flex; align-items: center; gap: 8px; }
.theme-row svg { width: 17px; height: 17px; color: var(--muted); }
.theme-switch { position: relative; width: 46px; height: 27px; display: inline-block; flex: none; }
.theme-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.theme-slider { position: absolute; inset: 0; border-radius: 999px; background: #d7dce5; border: 1px solid #ccd3dd; cursor: pointer; transition: background-color .22s var(--ease), border-color .22s var(--ease); }
.theme-slider::before { content: ""; position: absolute; width: 21px; height: 21px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 2px 7px rgba(15,23,42,.22); transition: transform .22s var(--ease); }
.theme-switch input:checked + .theme-slider { background: var(--brand-bright); border-color: var(--brand-bright); }
.theme-switch input:checked + .theme-slider::before { transform: translateX(19px); }
.theme-switch input:focus-visible + .theme-slider { outline: 3px solid color-mix(in srgb, var(--brand-bright) 24%, transparent); outline-offset: 3px; }
.theme-floating { position: fixed; top: 18px; right: 18px; z-index: 60; padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-sm); }

/* Layout */
.container { width: auto; margin-left: 252px; padding: 38px 40px 72px; max-width: none; }
.dashboard-container { max-width: 1720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 26px; margin-bottom: 26px; }
.page-head h1 { font-size: clamp(34px, 3vw, 42px); line-height: 1.04; letter-spacing: -.045em; margin: 6px 0 9px; color: var(--text); font-weight: 760; }
.page-head p { margin: 0; font-size: 15px; max-width: 760px; }
.clean-head { align-items: flex-start; }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; font-size: 11px; color: var(--brand-bright); font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.limit-badge { border: 1px solid var(--line); background: var(--surface); padding: 9px 13px; border-radius: 999px; color: var(--muted); font-size: 13px; box-shadow: var(--shadow-xs); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

/* Buttons */
.btn {
  min-height: 44px;
  border-radius: 11px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.btn .ui-icon { width: 17px; height: 17px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-bright) 22%, transparent); outline-offset: 2px; }
.primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 8px 20px rgba(17,24,39,.12); }
.primary:hover { background: var(--brand-bright); color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--brand-bright) 24%, transparent); }
.secondary { background: var(--surface); border-color: var(--line); color: var(--text-2); box-shadow: var(--shadow-xs); }
.secondary:hover { border-color: color-mix(in srgb, var(--brand-bright) 35%, var(--line)); background: var(--surface-2); color: var(--text); }
.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 18%, var(--line)); color: var(--danger); }
.compact { min-height: 38px; padding: 0 12px; font-size: 13px; }
.full-btn { width: 100%; height: 50px; }
.actions-row { display: flex; gap: 10px; }
.actions-end { justify-content: flex-end; align-items: flex-end; }

/* Alerts */
.alert { padding: 13px 15px; border-radius: 12px; margin: 0 0 20px; font-size: 14px; border: 1px solid; box-shadow: var(--shadow-xs); }
.alert.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 18%, var(--line)); color: var(--success); }
.alert.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 18%, var(--line)); color: var(--danger); }

/* Forms */
.create-card { padding: 26px; margin-bottom: 24px; }
.create-card h2 { margin: 0 0 20px; font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field input, .field textarea, .field select, .team-password, .custom-date-range input, .period-select-wrap select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  padding: 0 13px;
  outline: none;
  font-size: 14px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 45%, transparent);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background-color .16s var(--ease);
}
.field textarea { padding: 12px 13px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: color-mix(in srgb, var(--muted) 74%, transparent); }
.field input:focus, .field textarea:focus, .field select:focus, .team-password:focus, .custom-date-range input:focus, .period-select-wrap select:focus { border-color: var(--brand-bright); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-bright) 13%, transparent); }
.field input[readonly] { background: var(--surface-2); color: var(--muted); }
.field-help { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.required { color: var(--danger); }
.editor-card { padding: 28px; }
.section-title { display: grid; gap: 4px; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.section-title strong { font-size: 16px; }
.section-title span { font-size: 13px; color: var(--muted); }
.editor-grid { grid-template-columns: 1fr; }
.editor-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }
.url-prefix-field { display: flex; align-items: center; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 11px; overflow: hidden; transition: border-color .16s var(--ease), box-shadow .16s var(--ease); }
.url-prefix-field:focus-within { border-color: var(--brand-bright); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-bright) 13%, transparent); }
.url-prefix-field > span { height: 46px; display: flex; align-items: center; padding: 0 12px; background: var(--surface-2); border-right: 1px solid var(--line); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.url-prefix-field input { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; transition: color .16s var(--ease), transform .16s var(--ease); }
.back-link:hover { color: var(--brand-bright); transform: translateX(-2px); }
.back-link .ui-icon { width: 16px; height: 16px; }
.delay-setting { display: grid; grid-template-columns: minmax(0, 240px) 1fr; gap: 18px; align-items: end; }
.delay-setting .field-help { padding-bottom: 13px; }

/* Metrics */
.dashboard-head { align-items: center; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.metric-card { min-height: 150px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand-bright) 20%, var(--line)); }
.metric-top { display: flex; align-items: center; gap: 10px; }
.metric-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--brand-bright); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand-bright) 14%, var(--line)); }
.metric-icon .ui-icon { width: 17px; height: 17px; }
.metric-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.metric-card strong { font-size: 36px; line-height: 1; letter-spacing: -.045em; color: var(--text); font-weight: 760; font-variant-numeric: tabular-nums; }
.metric-card > span { font-size: 12.5px; color: var(--muted); }

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .9fr); gap: 18px; margin-bottom: 18px; }
.analytics-card, .recent-card { padding: 22px; min-height: 370px; }
.card-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.card-section-head > div { display: grid; gap: 3px; }
.card-section-head strong, .table-title-row strong { font-size: 15px; color: var(--text); font-weight: 750; }
.card-section-head span, .table-title-row span { font-size: 12.5px; color: var(--muted); }
.analytics-head { align-items: flex-start; }
.period-filter { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.period-select-wrap { position: relative; min-width: 170px; }
.period-select-wrap .ui-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.period-select-wrap select { min-height: 40px; padding: 0 34px 0 36px; appearance: none; cursor: pointer; font-size: 13px; font-weight: 600; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 11px) 17px; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; }
.custom-date-range { display: flex; align-items: flex-end; gap: 7px; padding: 8px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; box-shadow: var(--shadow-xs); }
.custom-date-range label { display: grid; gap: 4px; }
.custom-date-range label > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.custom-date-range input { min-height: 38px; width: 136px; padding: 0 9px; font-size: 12.5px; }

.chart-shell { min-height: 265px; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; }
.chart-scroll { overflow-x: auto; overflow-y: visible; padding: 2px 2px 8px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.chart-scroll::-webkit-scrollbar { height: 6px; }
.chart-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.chart-bars { height: 220px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(8px, 1fr); align-items: end; gap: 5px; padding: 18px 4px 0; position: relative; background-image: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), color-mix(in srgb, var(--line) 66%, transparent) 25%); }
.chart-column { height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; border-radius: 7px; outline: none; transition: background-color .16s var(--ease); }
.chart-column > span { display: block; width: min(72%, 18px); min-height: 3px; background: linear-gradient(180deg, #7594c7 0%, var(--brand) 100%); border-radius: 6px 6px 3px 3px; opacity: .92; box-shadow: 0 3px 8px color-mix(in srgb, var(--brand) 12%, transparent); transform-origin: bottom; transition: transform .16s var(--ease), opacity .16s var(--ease), filter .16s var(--ease); }
.chart-column:hover, .chart-column:focus-visible { background: color-mix(in srgb, var(--brand-bright) 5%, transparent); }
.chart-column:hover > span, .chart-column:focus-visible > span { opacity: 1; transform: scaleX(1.15); filter: saturate(1.15); }
.chart-column::after { content: attr(data-tooltip); position: absolute; left: 50%; top: 8px; z-index: 8; padding: 7px 9px; border-radius: 8px; background: var(--tooltip); color: var(--bg); font-size: 11.5px; font-weight: 650; white-space: nowrap; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transform: translate(-50%, -4px); transition: opacity .14s var(--ease), transform .14s var(--ease); }
.chart-column:hover::after, .chart-column:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 7px; font-variant-numeric: tabular-nums; }

.recent-list { display: grid; gap: 9px; }
.recent-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; background: var(--surface); transition: border-color .16s var(--ease), background-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease); }
.recent-item:hover { border-color: color-mix(in srgb, var(--brand-bright) 26%, var(--line)); background: var(--surface-2); transform: translateX(2px); box-shadow: var(--shadow-xs); }
.recent-item > div { display: grid; gap: 3px; min-width: 0; }
.recent-item strong { font-size: 13.5px; }
.recent-item > div span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-mini { color: var(--muted); font-size: 13px; padding: 20px 4px; }

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { text-align: left; padding: 15px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .065em; background: var(--surface-2); font-weight: 800; }
tbody tr { transition: background-color .15s var(--ease); }
tbody tr:hover { background: color-mix(in srgb, var(--brand-bright) 3.5%, var(--surface)); }
tr:last-child td { border-bottom: 0; }
.table-title-row { padding: 19px 21px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.table-title-row > div { display: grid; gap: 3px; }
.deeplink-table { min-width: 1040px; }
.deeplink-table th:last-child, .deeplink-table td:last-child { text-align: right; }
.short-url-cell { display: flex; align-items: center; gap: 8px; }
.short-url-cell strong { font-size: 13px; font-weight: 700; }
.destination-cell { display: flex; align-items: center; gap: 8px; max-width: 520px; }
.destination-cell > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.type-chip, .delay-chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 10.5px; font-weight: 750; flex: none; white-space: nowrap; }
.type-chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.delay-chip { background: var(--brand-soft); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand-bright) 12%, var(--line)); }
.delay-chip .ui-icon { width: 13px; height: 13px; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.row-actions form { margin: 0; }
.icon-btn { position: relative; width: 34px; height: 34px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; line-height: 1; transition: color .15s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease); }
.icon-btn .ui-icon { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-3); border-color: var(--line); color: var(--text); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(.94); }
.icon-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-bright) 20%, transparent); outline-offset: 2px; }
.icon-btn[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 7px); left: 50%; padding: 6px 8px; border-radius: 7px; background: var(--tooltip); color: var(--bg); font-size: 10.5px; font-weight: 650; white-space: nowrap; opacity: 0; pointer-events: none; transform: translate(-50%, 3px); box-shadow: var(--shadow-sm); transition: opacity .12s var(--ease), transform .12s var(--ease); z-index: 20; }
.icon-btn[data-tooltip]:hover::after, .icon-btn[data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.icon-success { display: none; color: var(--success); }
.icon-btn.is-copied .icon-default { display: none; }
.icon-btn.is-copied .icon-success { display: inline-flex; }
.danger-icon { color: var(--danger); }
.danger-icon:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 20%, var(--line)); color: var(--danger); }
.empty-row { text-align: center !important; color: var(--muted); padding: 42px !important; }
.actions-col { width: 164px; }
.status { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 10.5px; font-weight: 750; padding: 5px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 10%, transparent); }
.status.on { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 14%, var(--line)); }
.status.off { background: var(--surface-3); color: var(--muted); border-color: var(--line); }

/* Team/Admin */
.team-inline { display: flex; gap: 8px; align-items: center; }
.team-password { height: 40px; min-width: 160px; padding: 0 11px; }
.team-actions { display: flex; gap: 7px; align-items: center; }
.team-actions form { margin: 0; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--brand-bright) 12%, transparent), transparent 34%), var(--bg); }
.auth-card { width: min(460px, 100%); padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); }
.wide-card { width: min(760px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { width: 44px; height: 44px; object-fit: contain; }
.auth-brand strong { font-size: 24px; letter-spacing: -.035em; font-weight: 700; }
.auth-brand strong span { color: var(--brand-bright); }
.auth-card h1 { margin: 6px 0 10px; font-size: 32px; line-height: 1.1; letter-spacing: -.04em; color: var(--text); font-weight: 760; }
.auth-card p { margin: 0 0 26px; font-size: 14px; }
.auth-card form:not(.form-grid) { display: grid; gap: 15px; }
.auth-links { display: flex; justify-content: flex-end; margin-top: -4px; }
.auth-links a, .auth-back { font-size: 13px; color: var(--muted); text-decoration: none; font-weight: 650; }
.auth-links a:hover, .auth-back:hover { color: var(--brand-bright); }
.auth-back { text-align: center; margin-top: 3px; }
.password-control { position: relative; width: 100%; }
.password-control > input { padding-right: 50px !important; }
.password-toggle { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease); }
.password-toggle:hover, .password-toggle:focus-visible { background: var(--surface-3); color: var(--text); outline: none; }
.password-toggle svg { width: 18px; height: 18px; }
.dev-helper { display: grid; gap: 6px; border: 1px dashed var(--line-strong); background: var(--surface-2); border-radius: 11px; padding: 14px; margin: 12px 0 16px; color: var(--muted); font-size: 12.5px; }
.dev-helper strong { color: var(--brand-bright); }
.dev-helper a { color: var(--text); font-weight: 750; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .recent-card { min-height: auto; }
}

@media (max-width: 780px) {
  .topbar { position: sticky; top: 0; width: 100%; height: auto; min-height: 68px; padding: 10px 12px; flex-direction: row; align-items: center; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { min-height: 46px; margin: 0; padding: 4px 6px; }
  .brand-mark-wrap { width: 34px; height: 34px; }
  .brand img { width: 25px; height: 25px; }
  .brand-wordmark { font-size: 16px; }
  .topbar nav { width: auto; flex: none; flex-direction: row; gap: 3px; overflow-x: auto; }
  .topbar .nav-link { min-height: 40px; padding: 0 9px; font-size: 12px; }
  .topbar .nav-link .ui-icon { width: 17px; height: 17px; }
  .topbar .nav-logout { margin-top: 0; border-top: 0; }
  .theme-sidebar { margin: 0 0 0 6px; padding: 0; border: 0; }
  .theme-row .theme-label { display: none; }
  .container { margin-left: 0; padding: 28px 16px 58px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head h1 { font-size: 34px; }
  .dashboard-head .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 132px; padding: 16px; }
  .metric-card strong { font-size: 31px; }
  .analytics-card, .recent-card { min-height: auto; padding: 18px; }
  .analytics-head { flex-direction: column; }
  .period-filter { width: 100%; align-items: stretch; }
  .period-select-wrap { width: 100%; }
  .custom-date-range { flex-wrap: wrap; }
  .custom-date-range label { flex: 1 1 120px; }
  .custom-date-range input { width: 100%; }
  .custom-date-range .btn { flex: 1 1 100%; }
  .table-title-row { align-items: flex-start; flex-direction: column; }
  .table-title-row .btn { width: 100%; }
  .actions-end { align-items: stretch; }
  .delay-setting { grid-template-columns: 1fr; }
  .delay-setting .field-help { padding-bottom: 0; }
  .team-inline { min-width: 280px; }
  .auth-card { padding: 28px 22px; }
  .auth-card h1 { font-size: 30px; }
  .theme-floating { top: 12px; right: 12px; }
}

@media (max-width: 560px) {
  .brand-wordmark { display: none; }
  .topbar .nav-link span { display: none; }
  .topbar .nav-link { width: 40px; justify-content: center; padding: 0; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 124px; }
  .page-head h1 { font-size: 31px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
