:root {
  --black: #07090b;
  --surface-0: #0b0e12;
  --surface-1: #11151a;
  --surface-2: #171c22;
  --surface-3: #20262d;
  --line: #2a3038;
  --text: #f4f6f8;
  --muted: #929ba5;
  --red: #e21d2f;
  --red-dark: #7b1620;
  --green: #24c875;
  --blue: #3a91ff;
  --amber: #f5a524;
  --radius: 12px;
  --shadow: 0 18px 45px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--black);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--black); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 70% -10%, #242a31 0, var(--black) 38%); }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--red); color: #fff; padding: 12px 16px; border-radius: 8px; text-decoration: none; }
.skip-link:focus { top: 12px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(115deg, rgba(7,9,11,.96), rgba(7,9,11,.7)), radial-gradient(circle at 80% 20%, #3a1116, transparent 42%); }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 16px; background: rgba(17,21,26,.96); box-shadow: var(--shadow); }
.login-card h1 { margin: 10px 0 8px; font-size: 32px; }
.login-card form { display: grid; gap: 10px; margin-top: 28px; }
.login-card label { color: #cbd1d7; font-size: 13px; font-weight: 650; }
.login-card input { min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: #090c0f; color: var(--text); outline: none; }
.login-card input:focus, .global-search:focus-within, select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(226,29,47,.18); }
.second-factor-fields { display: grid; gap: 10px; }
.check-label { min-height: 44px; display: flex; align-items: center; gap: 10px; }
.check-label input { min-height: auto; width: 20px; height: 20px; accent-color: var(--red); }
.form-error { min-height: 20px; margin: 2px 0; color: #ff7180; font-size: 13px; }
.primary-button { min-height: 48px; border: 0; border-radius: 8px; padding: 0 18px; background: linear-gradient(135deg, var(--red), #b31221); color: #fff; font-weight: 750; cursor: pointer; box-shadow: 0 8px 24px rgba(226,29,47,.2); }
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; background: var(--surface-3); color: var(--text); cursor: pointer; }
.security-panel { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 14px; margin-bottom: 14px; }
.security-form { display: grid; gap: 10px; margin-top: 18px; }
.security-form label { display: grid; gap: 6px; color: #cbd1d7; font-size: 13px; }
.security-form input { min-height: 48px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; background: #090c0f; color: var(--text); }
.enrollment-box { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-0); }
.enrollment-box img { display: block; width: min(240px, 100%); margin: 14px auto; border: 8px solid #fff; border-radius: 8px; }
.enrollment-box code { display: block; overflow-wrap: anywhere; padding: 10px; color: #fff; background: #050607; border-radius: 6px; text-align: center; }
.recovery-codes { margin-top: 16px; white-space: pre-wrap; padding: 16px; border: 1px solid var(--amber); border-radius: 8px; background: rgba(245,165,36,.08); font-family: ui-monospace, monospace; line-height: 1.7; }

.brand { height: 88px; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: 1fr 1fr; align-items: end; gap: 0 8px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.brand-login { height: auto; border: 0; padding: 0 0 18px; justify-content: start; grid-template-columns: auto auto auto; }
.brand-mark { grid-row: 1 / span 2; font-size: 37px; font-weight: 900; letter-spacing: -4px; font-style: italic; line-height: 1; }
.brand-copy { font-size: 9px; font-weight: 800; letter-spacing: 2px; align-self: start; color: #c8cdd2; }
.swiss-cross { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 2px; background: var(--red); color: #fff; font-weight: 900; font-size: 15px; grid-row: 1 / span 2; align-self: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 240px; display: flex; flex-direction: column; background: rgba(9,12,15,.98); border-right: 1px solid var(--line); }
.sidebar nav { padding: 12px 10px; overflow-y: auto; scrollbar-width: thin; }
.nav-item { display: flex; align-items: center; min-height: 41px; gap: 12px; margin: 2px 0; padding: 0 12px; border-radius: 7px; color: #cbd1d7; text-decoration: none; font-size: 13px; }
.nav-item span { width: 18px; color: #aeb5bd; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--surface-2); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(226,29,47,.6), rgba(123,22,32,.35)); color: #fff; box-shadow: inset 3px 0 var(--red); }
.owner-panel { margin-top: auto; min-height: 76px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.owner-panel strong, .owner-panel small { display: block; max-width: 115px; overflow: hidden; text-overflow: ellipsis; }
.owner-panel strong { font-size: 12px; }
.owner-panel small { color: var(--muted); margin-top: 3px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: #fff; font-weight: 800; font-size: 12px; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 8px; background: transparent; color: #d5d9dd; cursor: pointer; }
.icon-button:hover { background: var(--surface-3); }

.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; display: grid; grid-template-columns: minmax(260px, 760px) auto; justify-content: space-between; align-items: center; gap: 24px; padding: 12px 24px; background: rgba(7,9,11,.9); border-bottom: 1px solid rgba(42,48,56,.75); backdrop-filter: blur(18px); }
.menu-button { display: none; }
.global-search { height: 44px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface-1); }
.global-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.global-search input::placeholder { color: #777f88; }
.global-search kbd { padding: 3px 7px; border: 1px solid #343b43; border-radius: 5px; color: var(--muted); font-size: 11px; }
.clock { text-align: right; white-space: nowrap; }
.clock span, .clock strong { display: block; }
.clock span { color: var(--muted); font-size: 11px; }
.clock strong { margin-top: 2px; font-size: 16px; }

main { max-width: 1680px; margin: 0 auto; padding: 22px 24px 36px; }
.hero { min-height: 138px; display: flex; justify-content: space-between; align-items: center; padding: 24px 30px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(100deg, rgba(8,11,14,.96), rgba(19,24,29,.76)), radial-gradient(circle at 70% 45%, #3d464f, transparent 45%); box-shadow: var(--shadow); }
.hero h1 { margin: 6px 0; font-size: clamp(25px, 3vw, 39px); letter-spacing: -.8px; }
.hero p { margin: 0; color: #a8b0b8; }
.eyebrow { margin: 0; color: var(--red); font-size: 10px; font-weight: 850; letter-spacing: 2px; }
.quality-mark { padding-right: 3vw; color: #aeb5bc; border-left: 3px solid var(--red); padding-left: 18px; }
.quality-mark strong, .quality-mark span { display: block; }
.quality-mark strong { line-height: 1.15; }
.quality-mark span { margin-top: 8px; font-size: 9px; letter-spacing: 2px; }
.toolbar { min-height: 78px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.toolbar h1, .toolbar h2, .toolbar p { margin: 0; }
.toolbar h2 { font-size: 20px; }
.muted { color: var(--muted); }
.toolbar .muted { margin-top: 5px; font-size: 12px; }
.period-control { display: grid; grid-template-columns: auto auto; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.period-control select { min-height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 0 10px; background: var(--surface-1); color: var(--text); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.kpi { min-height: 95px; display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface-2), var(--surface-1)); }
.kpi-icon { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; font-weight: 900; }
.kpi-icon.red { color: #ff5262; background: rgba(226,29,47,.14); }
.kpi-icon.green { color: var(--green); background: rgba(36,200,117,.13); }
.kpi-icon.blue { color: var(--blue); background: rgba(58,145,255,.13); }
.kpi-icon.amber { color: var(--amber); background: rgba(245,165,36,.13); }
.kpi small, .kpi strong, .kpi em { display: block; }
.kpi small { color: #9da5ad; font-size: 11px; }
.kpi strong { margin-top: 5px; font-size: clamp(17px, 2vw, 24px); white-space: nowrap; }
.kpi em { margin-top: 3px; color: var(--muted); font-size: 10px; font-style: normal; }

.dashboard-grid { display: grid; grid-template-columns: 1.2fr 1.15fr .82fr; gap: 10px; margin-top: 10px; }
.panel { min-width: 0; min-height: 260px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface-1), #0e1216); }
.panel-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 15px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0; font-size: 14px; }
.panel-heading a { color: #57a4ff; text-decoration: none; font-size: 10px; }
.live-chip { padding: 3px 7px; border-radius: 99px; color: var(--green); background: rgba(36,200,117,.1); font-size: 9px; font-weight: 800; }
.data-list { padding: 5px 13px; }
.data-row { min-height: 43px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; border-bottom: 1px solid rgba(42,48,56,.55); }
.data-row:last-child { border-bottom: 0; }
.data-row strong, .data-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-row strong { font-size: 11px; }
.data-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.data-row time, .data-row .value { color: #d8dde2; font-size: 10px; }
.status { padding: 4px 7px; border-radius: 5px; color: var(--blue); background: rgba(58,145,255,.12); font-size: 9px; }
.empty-state { min-height: 150px; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 12px; }
.quick-actions { display: grid; gap: 7px; padding: 11px; }
.quick-action { min-height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 11px; border: 1px solid transparent; border-radius: 7px; background: var(--surface-2); color: #e1e5e8; text-decoration: none; font-size: 11px; }
.quick-action:hover { border-color: var(--red); }
.trend-chart { min-height: 205px; display: flex; align-items: end; gap: 9px; padding: 28px 16px 18px; }
.bar-group { flex: 1; min-width: 18px; height: 160px; display: flex; align-items: end; justify-content: center; gap: 3px; position: relative; padding-bottom: 20px; }
.bar { width: min(15px, 42%); min-height: 2px; border-radius: 3px 3px 0 0; }
.bar.revenue { background: var(--red); }
.bar.profit { background: #7f8994; }
.bar-label { position: absolute; bottom: 0; font-size: 9px; color: var(--muted); }
.status-banner { margin-bottom: 12px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: #dce1e5; font-size: 12px; }
.status-banner.error { border-color: var(--red-dark); color: #ff9da6; }
.connection-status { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; z-index: 100; transform: translateX(-50%); max-width: calc(100vw - 24px); padding: 10px 16px; border: 1px solid #b97b20; border-radius: 8px; background: #2b1d09; color: #ffd58b; box-shadow: var(--shadow); font-size: 12px; font-weight: 750; text-align: center; }
.pwa-install-button { width: calc(100% - 20px); min-height: 44px; margin: auto 10px 10px; border: 1px solid rgba(226,29,47,.45); cursor: pointer; text-align: left; }
.pwa-install-button:hover { border-color: var(--red); }
.pwa-install-button[hidden] { display: none; }

.search-results { display: grid; gap: 12px; }
.domain-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 12px; }
.domain-card { min-height: 126px; display: block; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface-2), var(--surface-1)); text-decoration: none; }
.domain-card:hover { border-color: #48515b; transform: translateY(-1px); }
.domain-card h2 { margin: 0 0 9px; font-size: 15px; }
.domain-card p { margin: 5px 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.domain-card .status { display: inline-block; margin-top: 8px; }
.detail-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 9px 0; background: rgba(255,255,255,0.02); }
.detail-row { display: grid; grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-row strong { color: var(--muted); text-transform: capitalize; }
.detail-row span { overflow-wrap: anywhere; }
.task-form, .identity-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.task-form[hidden], .identity-form[hidden] { display: none; }
.task-form .panel-heading, .task-form .task-description, .task-form .form-error,
.identity-form .panel-heading, .identity-form .wide-field, .identity-form .form-error { grid-column: 1 / -1; }
.task-form label, .identity-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.task-form input, .task-form select, .task-form textarea,
.identity-form input, .identity-form select, .identity-form textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 9px; }
.task-form textarea, .identity-form textarea { min-height: 82px; resize: vertical; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.task-actions button, .task-actions input, .task-actions select { min-height: 42px; }
.task-actions input, .task-actions select { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 9px; }
.search-group { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface-1); }
.search-group h2 { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: #cbd1d7; }
.search-result { display: block; padding: 13px 16px; border-bottom: 1px solid rgba(42,48,56,.6); text-decoration: none; }
.search-result:last-child { border: 0; }
.search-result:hover { background: var(--surface-2); }
.search-result strong, .search-result small { display: block; }
.search-result small { margin-top: 5px; color: var(--muted); }
.pending-card { max-width: 720px; margin: 12vh auto 0; padding: 38px; border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: var(--radius); background: var(--surface-1); box-shadow: var(--shadow); }
.pending-card h1 { margin: 10px 0; }
.pending-card p { line-height: 1.6; }
.inline-button { display: inline-flex; align-items: center; margin-top: 12px; text-decoration: none; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .quick-panel { grid-column: 1 / -1; min-height: auto; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  .security-panel { grid-template-columns: 1fr; }
  .task-form, .identity-form { grid-template-columns: 1fr 1fr; }
  .app-shell { display: block; }
  .workspace { width: 100%; }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-scrim { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(0,0,0,.64); }
  .topbar { height: auto; min-height: 68px; grid-template-columns: auto minmax(0, 1fr); gap: 9px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; }
  .menu-button { display: block; }
  .clock { display: none; }
  .global-search { min-width: 0; }
  .global-search kbd { display: none; }
  main { padding: 14px 12px max(28px, env(safe-area-inset-bottom)); }
  .hero { min-height: 120px; padding: 20px; }
  .quality-mark { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-panel { grid-column: auto; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .detail-row { grid-template-columns: 1fr; gap: 3px; }
  .task-form, .identity-form { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px; }
  .hero { border-radius: 10px; }
  .hero h1 { font-size: 25px; }
  .toolbar { align-items: end; }
  .toolbar h2 { font-size: 18px; }
  .period-control { grid-template-columns: 1fr; gap: 4px; }
  .period-control select { max-width: 155px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { min-height: 88px; padding: 11px; gap: 9px; }
  .kpi:nth-child(4) { grid-column: 1 / -1; }
  .kpi-icon { width: 32px; height: 32px; }
  .kpi strong { font-size: 17px; }
  .quick-actions { grid-template-columns: 1fr; }
  .panel { min-height: 230px; }
  .trend-chart { overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
