@font-face {
  font-family: "Google Sans Code";
  src: url("./assets/fonts/GoogleSansCode-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #edf4f4;
  --surface: #ffffff;
  --surface-alt: #f2f8f7;
  --control: #fbfefe;
  --control-muted: #e5eff0;
  --ink: #17333a;
  --muted: #5b7278;
  --line: #cddfe0;
  --line-strong: #acc7c9;
  --nav: #15353b;
  --nav-hover: #24545b;
  --nav-border: #35636a;
  --nav-muted: #aac6c9;
  --accent: #008a76;
  --accent-hover: #00715f;
  --accent-soft: #dff3ee;
  --accent-border: #90cfbf;
  --coral: #e2536b;
  --coral-soft: #fde8ec;
  --gold: #b87400;
  --gold-soft: #fff0cf;
  --cyan: #168bb0;
  --cyan-soft: #def3f8;
  --pattern-dot: rgba(22, 139, 176, 0.12);
  --pattern-coral-dot: rgba(226, 83, 107, 0.08);
  --danger: #bd3347;
  --danger-soft: #fde8eb;
  --danger-border: #efbbc3;
  --warning: #986000;
  --warning-soft: #fff0cf;
  --warning-border: #e7c47f;
  --success: #08745f;
  --success-soft: #ddf3ec;
  --success-border: #a6d8c8;
  --login-bg: #e5efef;
  --row-hover: #e8f4f2;
  --focus-ring: rgba(0, 138, 118, 0.17);
  --overlay: rgba(15, 42, 47, 0.52);
  --toast-bg: #17333a;
  --on-accent: #ffffff;
  --shadow: 0 9px 26px rgba(27, 75, 79, 0.09), 0 1px 2px rgba(0, 138, 118, 0.05);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #171e25;
  --surface-alt: #1c252d;
  --control: #131a21;
  --control-muted: #222c35;
  --ink: #e8edf2;
  --muted: #9aa8b5;
  --line: #2b3741;
  --line-strong: #3a4854;
  --nav: #0b1015;
  --nav-hover: #1d2b32;
  --nav-border: #253039;
  --nav-muted: #8f9ca8;
  --accent: #42b9a2;
  --accent-hover: #55c9b2;
  --accent-soft: #14342f;
  --accent-border: #296a5e;
  --coral: #f0838e;
  --coral-soft: #3a252b;
  --gold: #e3ad55;
  --gold-soft: #352d20;
  --cyan: #64b8d4;
  --cyan-soft: #19313b;
  --pattern-dot: rgba(100, 184, 212, 0.11);
  --pattern-coral-dot: rgba(240, 131, 142, 0.06);
  --danger: #ef8c8c;
  --danger-soft: #382326;
  --danger-border: #704044;
  --warning: #e6b668;
  --warning-soft: #362d1d;
  --warning-border: #65522f;
  --success: #69c89e;
  --success-soft: #17342a;
  --success-border: #2d6450;
  --login-bg: #0c1116;
  --row-hover: #202d34;
  --focus-ring: rgba(66, 185, 162, 0.2);
  --overlay: rgba(0, 0, 0, 0.68);
  --toast-bg: #e8edf2;
  --on-accent: #071713;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, var(--pattern-dot) 1px, transparent 1px),
    radial-gradient(circle, var(--pattern-coral-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  transition: background-color 160ms ease, color 160ms ease;
}
::selection { background: var(--coral-soft); color: var(--ink); }

button, input, select { font: inherit; }
button { cursor: pointer; transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease; }
button:disabled { cursor: wait; opacity: 0.6; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: 0; }
h2 { font-size: 17px; letter-spacing: 0; }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: var(--login-bg);
  background-image: radial-gradient(circle, var(--pattern-dot) 1px, transparent 1px);
  background-size: 20px 20px;
}

.login-panel {
  width: min(920px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 0.8fr);
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(24, 33, 42, 0.12);
}

.login-brand {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}
.login-brand .theme-toggle { margin-left: auto; }

.login-copy {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: #1b2631;
  color: #fff;
  overflow: hidden;
}

.login-copy::before { position: absolute; top: -64px; right: -48px; width: 190px; height: 190px; border: 18px solid rgba(80, 195, 174, 0.18); transform: rotate(18deg); content: ""; }
.login-copy::after { position: absolute; right: 34px; bottom: 28px; color: #f0848e; content: "✦"; font-size: 34px; line-height: 1; }
.login-copy > * { position: relative; z-index: 1; }

.login-copy h1 { margin-top: 14px; font-size: 36px; }
.login-copy > p:last-child { margin-top: 16px; color: #b7c2cc; line-height: 1.7; }
.eyebrow { color: #50c3ae; font-size: 12px; font-weight: 800; }

.login-form {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 48px;
}
.login-form .text-button { justify-self: center; }
.login-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }

.brand-mark { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 7px; background: #38b79f; color: #10221e; font-weight: 900; box-shadow: 4px 4px 0 rgba(223, 101, 114, 0.72); }

.app-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; background: var(--nav); color: #fff; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; border-bottom: 1px solid var(--nav-border); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: var(--nav-muted); font-size: 11px; }
.nav { display: grid; gap: 7px; margin-top: 22px; }
.nav-item { position: relative; width: 100%; min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 14px 0 17px; border: 0; border-radius: 7px; background: transparent; color: #bec8d2; text-align: left; }
.nav-icon { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover, .nav-item.active { background: var(--nav-hover); color: #fff; }
.nav-item.active::before { position: absolute; top: 9px; bottom: 9px; left: 6px; width: 3px; border-radius: 2px; background: #52c7b0; box-shadow: 0 12px 0 #f0838e; content: ""; }
.account-box { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--nav-border); }
.account-box span, .account-box small { display: block; }
.account-box small { margin-top: 4px; color: #98a5b2; }
body[data-role="admin"] .client-nav, body[data-role="admin"] .client-view { display: none; }
body[data-role="admin"] .client-only { display: none; }
body[data-role="client"] .admin-nav, body[data-role="client"] .admin-view { display: none; }

.workspace { min-width: 0; padding: 26px; background: color-mix(in srgb, var(--bg) 91%, transparent); }
.topbar { min-height: 66px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.topbar h1 { position: relative; display: inline-block; }
.topbar h1::after { position: absolute; right: -19px; top: -5px; color: var(--coral); content: "✦"; font-size: 13px; }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.topbar p, .section-head p { margin-top: 6px; color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button, .danger-button, .text-button, .icon-button {
  border: 0;
  border-radius: 7px;
}
.primary-button, .secondary-button, .danger-button { min-height: 40px; padding: 0 15px; font-weight: 700; }
.primary-button { background: var(--accent); color: var(--on-accent); }
.primary-button:hover { background: var(--accent-hover); }
.secondary-button { border: 1px solid var(--line); background: var(--control); color: var(--ink); }
.secondary-button:hover { background: var(--surface-alt); }
.danger-button { background: var(--danger-soft); color: var(--danger); }
.danger-button.large { min-height: 44px; }
.text-button { padding: 4px 0; background: transparent; color: var(--accent); font-weight: 800; }
.text-button.inline { margin-left: 10px; }
.danger-text { color: var(--danger); }
.icon-button { width: 34px; height: 34px; background: var(--control-muted); color: var(--ink); font-size: 22px; }
.compact { min-height: 34px; padding: 0 11px; font-size: 12px; }
.theme-toggle { display: inline-flex; min-height: 40px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--control); color: var(--ink); font-weight: 700; }
.theme-toggle:hover { border-color: var(--line-strong); background: var(--surface-alt); }
.theme-indicator { width: 15px; height: 15px; border: 1.5px solid currentColor; border-radius: 50%; box-shadow: inset 6px 0 0 currentColor; }

.view { display: none; }
.view.active { display: block; animation: panel-in 180ms ease-out; }
@keyframes panel-in { from { transform: translateY(4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(155px, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card { position: relative; min-width: 0; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.metric-card::after { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border: 1px solid currentColor; transform: rotate(45deg); color: var(--accent); content: ""; opacity: 0.65; }
.metric-card:nth-child(2) { border-top-color: var(--coral); }
.metric-card:nth-child(2)::after { color: var(--coral); }
.metric-card:nth-child(3) { border-top-color: var(--gold); }
.metric-card:nth-child(3)::after { color: var(--gold); }
.metric-card:nth-child(4) { border-top-color: var(--cyan); }
.metric-card:nth-child(4)::after { color: var(--cyan); }
:root:not([data-theme="dark"]) .metric-card:nth-child(1) { background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft)); }
:root:not([data-theme="dark"]) .metric-card:nth-child(2) { background: color-mix(in srgb, var(--surface) 92%, var(--coral-soft)); }
:root:not([data-theme="dark"]) .metric-card:nth-child(3) { background: color-mix(in srgb, var(--surface) 92%, var(--gold-soft)); }
:root:not([data-theme="dark"]) .metric-card:nth-child(4) { background: color-mix(in srgb, var(--surface) 92%, var(--cyan-soft)); }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card-head { min-height: 34px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-card strong { margin-top: 10px; overflow-wrap: anywhere; font-size: 25px; }
.metric-card small { margin-top: 9px; color: var(--muted); font-size: 12px; }

.split-layout, .two-column { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.85fr); gap: 18px; }
.two-column.wide-left { grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1.1fr); }
.section-block { position: relative; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
:root:not([data-theme="dark"]) .section-block { border-color: color-mix(in srgb, var(--line) 82%, var(--accent-border)); }
.section-block::before { position: absolute; top: -1px; left: 18px; width: 46px; height: 3px; background: var(--coral); content: ""; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; }
.section-head h2::before { width: 7px; height: 7px; border: 1px solid var(--coral); transform: rotate(45deg); content: ""; }
.finance-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.segmented-control { display: inline-grid; grid-auto-flow: column; gap: 3px; margin-bottom: 16px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--control-muted); }
.segmented-control button { min-height: 34px; padding: 0 16px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 700; }
.segmented-control button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(23, 33, 43, 0.12); }
.customer-create { max-width: 760px; }
.compact-search { max-width: 290px; }

.row-list { display: grid; gap: 9px; }
.row-item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 64px; overflow: hidden; padding: 11px 12px 11px 15px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); }
.row-item::before { position: absolute; top: 11px; bottom: 11px; left: 0; width: 3px; background: var(--cyan); content: ""; }
:root:not([data-theme="dark"]) .row-item:hover { border-color: var(--accent-border); background: color-mix(in srgb, var(--surface-alt) 82%, var(--accent-soft)); }
.row-item strong, .row-item small { display: block; }
.row-item strong { overflow-wrap: anywhere; }
.row-item small { margin-top: 5px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.row-value { text-align: right; font-weight: 800; }
.row-value.danger { color: var(--danger); }
.row-value.warning { color: var(--warning); }
.row-value.success { color: var(--success); }

.service-grid { display: grid; grid-template-columns: repeat(2, minmax(340px, 1fr)); gap: 16px; }
.service-card { position: relative; min-width: 0; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-top: 3px solid var(--coral); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.service-card:nth-child(even) { border-top-color: var(--cyan); }
.service-card::after { position: absolute; top: -17px; right: -17px; width: 34px; height: 34px; border: 1px solid var(--gold); transform: rotate(45deg); content: ""; opacity: 0.75; }
.service-head { display: flex; justify-content: space-between; gap: 14px; }
.service-head > div { min-width: 0; }
.service-head h2 { display: inline; margin-left: 7px; overflow-wrap: anywhere; }
.service-head p { margin: 7px 0 0 17px; color: var(--muted); font-family: Consolas, monospace; font-size: 12px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #aeb6be; }
.status-dot.online { background: #28a46f; box-shadow: 0 0 0 3px #dcf2e8; }
.service-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 18px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.service-specs > span { min-width: 0; padding: 12px; overflow-wrap: anywhere; background: var(--surface-alt); font-size: 13px; }
.service-specs small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.expiry-strip { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 8px 7px 12px; border-left: 3px solid var(--accent); border-radius: 7px; background: var(--accent-soft); color: var(--success); font-weight: 800; }
.expiry-strip.urgent { background: var(--warning-soft); color: var(--warning); }
.service-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.marketplace-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding: 2px 2px 17px; border-bottom: 1px solid var(--line); }
.marketplace-head h2 { margin-top: 6px; font-size: 22px; }
.marketplace-head p { margin-top: 7px; color: var(--muted); font-size: 13px; }
.marketplace-kicker { color: var(--coral); font-family: "Google Sans Code", ui-monospace, monospace; font-size: 11px; font-weight: 700; }
.marketplace-balance { display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 12px; min-width: 210px; padding: 12px 13px; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.marketplace-balance span { color: var(--muted); font-size: 11px; }
.marketplace-balance strong { grid-row: 2; font-size: 20px; }
.marketplace-balance button { grid-column: 2; grid-row: 1 / 3; }
.product-catalog { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 16px; }
.product-card { position: relative; min-width: 0; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.product-card.tone-1 { border-top-color: var(--coral); }
.product-card.tone-2 { border-top-color: var(--gold); }
.product-card::after { position: absolute; top: -17px; right: -17px; width: 34px; height: 34px; border: 1px solid var(--cyan); transform: rotate(45deg); content: ""; opacity: 0.65; }
.product-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.product-card-head > div { min-width: 0; }
.product-card-head span { color: var(--muted); font-size: 11px; }
.product-card-head h2 { margin-top: 5px; overflow-wrap: anywhere; font-size: 17px; }
.inventory-badge { display: inline-flex; min-height: 24px; align-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.inventory-badge.available { border-color: var(--success-border); background: var(--success-soft); color: var(--success); }
.inventory-badge.sold-out { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.inventory-badge.review { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.product-spec-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 12px; padding: 13px; border-left: 3px solid var(--coral); background: var(--surface-alt); }
.product-spec-line strong { color: var(--accent); font-family: "Google Sans Code", ui-monospace, monospace; font-size: 19px; }
.product-spec-line span { color: var(--muted); font-size: 11px; font-weight: 800; }
.product-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.product-facts div { min-width: 0; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.product-facts dt { color: var(--muted); font-size: 10px; }
.product-facts dd { margin: 4px 0 0; overflow-wrap: anywhere; font-size: 12px; font-weight: 700; }
.product-purchase { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 17px; }
.product-purchase > div { display: flex; align-items: baseline; gap: 5px; }
.product-purchase strong { font-size: 23px; }
.product-purchase span { color: var(--muted); font-size: 11px; }
.purchase-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); gap: 1px; }
.purchase-summary span { min-width: 0; padding: 11px; background: var(--surface-alt); }
.purchase-summary small, .purchase-summary strong { display: block; }
.purchase-summary small { color: var(--muted); font-size: 10px; }
.purchase-summary strong { margin-top: 5px; overflow-wrap: anywhere; font-size: 13px; }
.purchase-total { display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 12px 14px; border-left: 3px solid var(--gold); border-radius: 7px; background: var(--gold-soft); color: var(--gold); }
.purchase-total strong { font-size: 23px; }
.review-note { padding: 11px 13px; border-left: 3px solid var(--cyan); background: var(--surface-alt); color: var(--muted); font-size: 12px; line-height: 1.6; }
.marketplace-orders { margin-top: 22px; }
.order-list { display: grid; border-top: 1px solid var(--line); }
.order-item { min-width: 0; padding: 16px 3px; border-bottom: 1px solid var(--line); }
.order-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-item-head strong, .order-item-head span { display: block; }
.order-item-head span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.order-item h3 { margin-top: 11px; overflow-wrap: anywhere; font-size: 15px; }
.order-item > p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.review-controls { display: grid; grid-template-columns: minmax(150px, 0.7fr) minmax(230px, 1.3fr) auto auto; align-items: end; gap: 10px; margin-top: 14px; padding: 13px; border-left: 3px solid var(--accent); background: var(--surface-alt); }
.review-controls label { min-width: 0; }
.review-controls button { white-space: nowrap; }
.order-result { margin-top: 13px; padding: 10px 12px; border-left: 3px solid var(--success); background: var(--success-soft); color: var(--success); font-size: 12px; font-weight: 700; }
.order-result.rejected { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.spec-badge { display: inline-flex; min-height: 27px; align-items: center; padding: 0 9px; border: 1px solid var(--accent-border); border-left: 3px solid var(--coral); border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-family: "Google Sans Code", ui-monospace, monospace; font-size: 12px; font-weight: 700; white-space: nowrap; }
.spec-badge.missing { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning); }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-active, .badge-paid { border: 1px solid var(--success-border); background: var(--success-soft); color: var(--success); }
.badge-suspended, .badge-unpaid, .badge-partial { border: 1px solid var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.badge-expired, .badge-cancelled { border: 1px solid var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.badge-pending { border: 1px solid var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.badge-provisioned { border: 1px solid var(--success-border); background: var(--success-soft); color: var(--success); }
.badge-rejected { border: 1px solid var(--danger-border); background: var(--danger-soft); color: var(--danger); }

.form-stack { display: grid; align-content: start; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select { width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--control); color: var(--ink); }
input::placeholder { color: var(--muted); opacity: 0.76; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
input[readonly] { background: var(--control-muted); color: var(--muted); }
.check-line { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 10px; }
.check-line input { width: 18px; min-height: 18px; }
.button-row { display: flex; gap: 10px; }
.binding-resource-status { padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); color: var(--muted); font-size: 12px; line-height: 1.5; }
.notification-settings { display: grid; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); }
.notification-master { color: var(--ink); font-weight: 800; }
.notification-option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { box-shadow: inset 0 2px 0 var(--cyan-soft); background: var(--surface-alt); color: var(--muted); font-size: 12px; }
:root:not([data-theme="dark"]) th { box-shadow: inset 0 2px 0 var(--cyan); background: #edf6f6; color: #436168; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
.customer-table { min-width: 1120px; }
.admin-vm-table { min-width: 1870px; }
.customer-table td { vertical-align: middle; }
.customer-table td strong, .customer-table td small { display: block; }
.customer-table td small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.customer-table code { font-family: Consolas, monospace; font-size: 12px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 230px; }
.table-actions button { min-height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--control); color: var(--ink); font-size: 11px; }
.table-actions button:hover { background: var(--surface-alt); }
.table-actions button.recharge-action { border-color: var(--accent-border); background: var(--success-soft); color: var(--accent); font-weight: 800; }
.table-actions button.recharge-action:hover { border-color: var(--accent); }
.table-actions button.danger-text { color: var(--danger); }
.vm-list-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.vm-list-tools .compact-search { width: min(330px, 36vw); }
.vm-identity strong, .vm-identity small, .vm-expiry strong, .vm-expiry small { display: block; }
.vm-identity small, .vm-expiry small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.vm-identity strong { font-family: Consolas, monospace; }
.vm-nat strong, .vm-nat small, .vm-access strong, .vm-access small { display: block; }
.vm-nat small, .vm-access small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.vm-nat code, .vm-access code, .service-specs code { font-family: Consolas, monospace; overflow-wrap: anywhere; white-space: normal; }
.copy-field { display: inline-flex; min-width: 0; align-items: center; gap: 6px; }
.copy-field code { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.copy-field button, .password-control button { min-height: 26px; padding: 0 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--control); color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 700; white-space: nowrap; }
.copy-field button:hover, .password-control button:hover { border-color: var(--accent); color: var(--accent); }
.password-control { display: inline-flex; min-width: 0; align-items: center; gap: 6px; }
.credentials-control .copy-field code, .password-control code { font-family: "Google Sans Code", ui-monospace, monospace; font-variant-ligatures: none; font-synthesis: none; letter-spacing: 0; }
.password-control code { min-width: 78px; font-size: 14px; font-weight: 560; line-height: 1.45; overflow-wrap: anywhere; white-space: normal; }
.password-control button[data-hold-password] { user-select: none; touch-action: none; }
.credentials-control { display: grid; gap: 6px; min-width: 190px; }
.credentials-control > span { display: block; }
.credential-edit-button { justify-self: start; min-height: 27px; padding: 0 8px; border: 1px solid var(--accent-border); border-radius: 5px; background: var(--success-soft); color: var(--accent); cursor: pointer; font-size: 10px; font-weight: 800; }
.credential-edit-button:hover { border-color: var(--accent); }
.privacy-note { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--success-soft); color: var(--muted); font-size: 12px; line-height: 1.65; }
.vm-expiry.urgent strong { color: var(--danger); }
.expiry-tag { display: inline-flex; min-height: 21px; align-items: center; margin-top: 5px; padding: 0 7px; border-radius: 5px; background: var(--danger-soft); color: var(--danger); font-size: 10px; font-weight: 800; }
.vm-extension { display: grid; grid-template-columns: 70px auto; gap: 6px; width: 142px; }
.vm-extension input { min-height: 32px; padding: 0 7px; }
.vm-extension button { min-height: 32px; padding: 0 9px; border: 1px solid var(--accent-border); border-radius: 6px; background: var(--success-soft); color: var(--accent); font-size: 11px; font-weight: 800; }
.vm-date-control { display: grid; grid-template-columns: 132px auto; gap: 6px; width: 190px; }
.vm-date-control input { min-height: 32px; padding: 0 7px; }
.vm-date-control button { min-height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--control); color: var(--ink); font-size: 11px; font-weight: 800; }
.vm-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 290px; }
.vm-actions button { min-height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--control); color: var(--ink); font-size: 11px; }
.vm-actions button:hover { background: var(--surface-alt); }
.vm-actions button:disabled { cursor: not-allowed; opacity: 0.45; }
.vm-actions button.vnc-action { border-color: var(--accent-border); background: var(--success-soft); color: var(--accent); font-weight: 800; }
.vm-actions button.stats-action, .stats-action { border-color: color-mix(in srgb, var(--cyan) 42%, var(--line)); background: var(--cyan-soft); color: var(--cyan); font-weight: 800; }
.vm-actions button.stats-action:hover, .stats-action:hover { border-color: var(--cyan); background: color-mix(in srgb, var(--cyan-soft) 78%, var(--surface)); }
.vm-actions button.force-action { color: var(--danger); }
.nat-address-preview { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid var(--success-border); border-radius: 7px; background: var(--success-soft); }
.nat-address-preview span { color: var(--muted); font-size: 12px; }
.nat-address-preview strong { font-family: Consolas, monospace; overflow-wrap: anywhere; text-align: right; }
.instance-count-button { min-height: 30px; padding: 0 9px; border: 1px solid var(--success-border); border-radius: 6px; background: var(--success-soft); color: var(--accent); font-size: 12px; font-weight: 800; }
.instance-count-button:hover { border-color: var(--accent); }
.password-state { display: inline-flex; min-height: 24px; align-items: center; padding: 0 8px; border-radius: 999px; background: var(--control-muted); color: var(--muted); font-size: 11px; font-weight: 800; }
.empty-state { padding: 25px 10px; color: var(--muted); text-align: center; }
.connection-state { margin-bottom: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); color: var(--muted); }
.connection-state.success { border-color: var(--success-border); background: var(--success-soft); color: var(--success); }
.connection-state.warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.connection-state.error { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.pve-health { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.pve-health > div { padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); text-align: center; }
.pve-health strong, .pve-health span { display: block; }
.pve-health strong { font-size: 22px; }
.pve-health span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.pve-health p { grid-column: 1 / -1; margin: 0; padding: 11px; border-radius: 7px; background: var(--warning-soft); color: var(--warning); font-size: 12px; line-height: 1.6; }

dialog { width: min(500px, calc(100vw - 28px)); padding: 0; overflow: hidden; border: 1px solid var(--line); border-top: 3px solid var(--coral); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 25px 80px rgba(15, 22, 29, 0.3); }
.wide-dialog { width: min(760px, calc(100vw - 28px)); }
.resource-stats-dialog { width: min(1120px, calc(100vw - 28px)); max-width: none; }
dialog::backdrop { background: var(--overlay); }
.dialog-form { display: grid; gap: 17px; padding: 21px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.dialog-head p { margin-top: 6px; color: var(--muted); font-size: 12px; }
.resource-stats-shell { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; max-height: min(88vh, 820px); overflow-x: hidden; overflow-y: auto; }
.resource-stats-shell > .dialog-head { padding: 20px 22px 16px; }
.resource-stats-toolbar { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 22px 14px; border-bottom: 1px solid var(--line); }
.resource-tabs { display: flex; min-width: 0; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
.resource-tabs button { min-width: 86px; min-height: 38px; padding: 0 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.resource-tabs button:hover { background: var(--surface-alt); color: var(--ink); }
.resource-tabs button.active { border-bottom-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.resource-refresh-controls { display: flex; align-items: flex-end; justify-content: flex-end; gap: 8px; }
.stats-auto-refresh { min-height: 36px; display: flex; grid-template-columns: none; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--control); color: var(--ink); font-size: 11px; font-weight: 700; white-space: nowrap; }
.stats-auto-refresh input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--accent); }
.stats-timeframe { min-width: 155px; grid-template-columns: auto; color: var(--muted); font-size: 11px; }
.stats-timeframe select { min-height: 36px; }
.resource-stats-status { min-width: 0; min-height: 38px; padding: 10px 22px; overflow-wrap: anywhere; background: var(--surface-alt); color: var(--muted); font-size: 12px; }
.resource-stats-status.success { color: var(--success); }
.resource-stats-status.error { background: var(--danger-soft); color: var(--danger); }
.resource-chart-panel { min-width: 0; padding: 18px 22px 22px; }
.resource-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.resource-chart-head h3 { margin: 0; font-size: 17px; }
.resource-chart-head p { margin-top: 5px; color: var(--muted); font-size: 11px; }
.resource-chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; color: var(--muted); font-size: 11px; font-weight: 700; }
.resource-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.resource-chart-legend i { width: 16px; height: 3px; display: inline-block; border-radius: 2px; }
.resource-chart { width: 100%; min-height: 330px; overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-alt); color: var(--muted); }
.resource-chart svg { display: block; width: 100%; min-width: 720px; height: auto; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis-label { fill: var(--muted); font-family: "Google Sans Code", ui-monospace, monospace; font-size: 10px; }
.chart-area { fill: var(--accent-soft); opacity: 0.82; }
.chart-series { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.resource-chart-loading, .resource-chart-empty { min-height: 328px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.resource-chart-summary { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.resource-chart-summary > div { min-width: 0; padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.resource-chart-summary span, .resource-chart-summary strong { display: block; }
.resource-chart-summary span { color: var(--muted); font-size: 10px; }
.resource-chart-summary strong { margin-top: 5px; overflow-wrap: anywhere; font-family: "Google Sans Code", ui-monospace, monospace; font-size: 14px; }
.renew-summary { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-radius: 7px; background: var(--surface-alt); }
.renew-summary strong { font-size: 22px; }
.danger-note { padding: 12px; border: 1px solid var(--danger-border); border-radius: 7px; background: var(--danger-soft); color: var(--danger); font-size: 13px; line-height: 1.6; }
.password-result { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--success-border); border-radius: 7px; background: var(--success-soft); color: var(--success); font-size: 12px; }
.password-result input { font-family: Consolas, monospace; font-weight: 800; }
.credential-reset-meta { display: block; color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.5; }
.password-reset-action { border-color: var(--warning-border) !important; background: var(--warning-soft) !important; color: var(--warning) !important; }
.verification-target { padding: 12px; border: 1px solid var(--success-border); border-radius: 7px; background: var(--success-soft); color: var(--success); overflow-wrap: anywhere; font-size: 13px; font-weight: 700; text-align: center; }
.support-contact { display: grid; gap: 8px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); text-align: center; }
.support-contact span { color: var(--muted); font-size: 12px; }
.support-contact input { min-height: 48px; border: 0; background: transparent; color: var(--ink); font-family: Consolas, monospace; font-size: 24px; font-weight: 800; text-align: center; }
.contact-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.binding-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.product-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.product-row-actions span { margin-right: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.owned-service-list { display: grid; gap: 10px; max-height: min(68vh, 660px); overflow-y: auto; }
.owned-service-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-alt); }
.owned-service-heading { grid-column: 1 / -1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.owned-service-heading strong, .owned-service-heading small { display: block; overflow-wrap: anywhere; }
.owned-service-heading small { margin-top: 4px; color: var(--muted); font-family: Consolas, monospace; font-size: 12px; }
.owned-service-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.owned-service-details > span { min-width: 0; overflow-wrap: anywhere; font-size: 12px; font-weight: 700; }
.owned-service-details .credentials-control { min-width: 0; }
.owned-service-details small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 500; }
.owned-service-actions { display: flex; justify-content: flex-end; gap: 8px; }
.runtime-state { display: inline-flex; min-height: 25px; align-items: center; padding: 0 9px; border-radius: 999px; background: var(--control-muted); color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.runtime-state.running { background: var(--success-soft); color: var(--success); }
.runtime-state.stopped { background: var(--warning-soft); color: var(--warning); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(390px, calc(100vw - 40px)); transform: translateY(130%); padding: 12px 16px; border-radius: 7px; background: var(--toast-bg); color: var(--surface); box-shadow: var(--shadow); transition: transform 160ms ease; }
.toast.show { transform: translateY(0); }

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

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .service-grid, .two-column.wide-left { grid-template-columns: 1fr; }
  .product-catalog { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
  .review-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { width: 100%; max-width: 100vw; grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .sidebar { position: sticky; z-index: 5; width: 100%; max-width: 100vw; min-width: 0; height: auto; padding: 12px; }
  .brand { padding: 0 4px 10px; }
  .nav { width: 100%; min-width: 0; grid-auto-flow: column; grid-auto-columns: minmax(126px, 1fr); overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item span { white-space: nowrap; }
  .account-box { display: none; }
  .workspace { width: 100%; max-width: 100vw; min-width: 0; padding: 16px; }
  .split-layout, .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .section-head, .vm-list-tools { align-items: stretch; flex-direction: column; }
  .vm-list-tools .compact-search { width: 100%; max-width: none; }
  .notification-option-grid { grid-template-columns: 1fr; }
  .owned-service-item { grid-template-columns: 1fr; }
  .owned-service-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-page { padding: 0; }
  .login-panel { min-height: 100vh; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; border: 0; border-radius: 0; }
  .login-copy { padding: 34px 26px; }
  .login-copy h1 { font-size: 30px; }
  .login-form { padding: 32px 26px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .section-head { align-items: stretch; flex-direction: column; }
  .compact-search { max-width: none; }
  .metric-grid, .service-grid, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .service-card { padding: 15px; }
  .service-specs { grid-template-columns: 1fr; }
  .service-actions .secondary-button { flex: 1 1 calc(50% - 8px); }
  .pve-health { grid-template-columns: 1fr; }
  .pve-health p { grid-column: 1; }
  .row-item { align-items: flex-start; grid-template-columns: 1fr; }
  .row-value { text-align: left; }
  .button-row { align-items: stretch; flex-direction: column; }
  .marketplace-head { align-items: stretch; flex-direction: column; }
  .marketplace-balance { width: 100%; }
  .product-catalog { grid-template-columns: 1fr; }
  .product-purchase { align-items: stretch; flex-direction: column; }
  .product-purchase button { width: 100%; }
  .review-controls { grid-template-columns: 1fr; }
  .review-controls button { width: 100%; }
  .finance-actions { width: 100%; justify-content: stretch; }
  .finance-actions button { flex: 1 1 calc(50% - 4px); }
  .resource-stats-dialog { width: calc(100vw - 12px); }
  .resource-stats-shell > .dialog-head, .resource-stats-toolbar, .resource-stats-status, .resource-chart-panel { padding-left: 14px; padding-right: 14px; }
  .resource-stats-toolbar { align-items: stretch; flex-direction: column-reverse; }
  .resource-refresh-controls { align-items: stretch; flex-wrap: wrap; justify-content: stretch; }
  .stats-auto-refresh, .resource-refresh-controls > button { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .stats-timeframe { width: 100%; }
  .resource-chart-head { align-items: flex-start; flex-direction: column; }
  .resource-chart-legend { justify-content: flex-start; }
  .resource-chart-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
