:root {
  color-scheme: light;
  --page: #f4f3ef;
  --surface: #ffffff;
  --surface-muted: #f8f8f6;
  --text: #1f252d;
  --muted: #6e7681;
  --line: #d9dde2;
  --line-strong: #b7bec7;
  --accent: #1867d5;
  --accent-dark: #0f4fa9;
  --danger: #b42318;
  --success: #147a4b;
  --warning: #a15c00;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(24, 103, 213, .12);
}

textarea { resize: vertical; line-height: 1.55; }

label {
  display: block;
  margin-bottom: 6px;
  color: #3f4752;
  font-weight: 600;
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; letter-spacing: -.02em; }
h2 { font-size: 18px; letter-spacing: -.01em; }

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: #182235;
  color: #fff;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -.04em;
}

.brand-mark.small { width: 42px; height: 42px; font-size: 15px; }

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
  font-weight: 600;
  white-space: nowrap;
}

.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.button.secondary:hover, .button.ghost:hover { background: #eceeeb; }
.button.ghost { background: transparent; color: #3f4752; border-color: var(--line-strong); }
.button.danger { background: #fff; color: var(--danger); border-color: #e2a8a3; }
.button.text { min-height: auto; padding: 2px 0; background: none; color: var(--accent); }
.button.compact { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.full-width { width: 100%; }

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: #f7f5ef;
}

.login-shell { width: min(420px, calc(100vw - 32px)); }

.login-card {
  border-top: 3px solid #182235;
  background: var(--surface);
  padding: 42px 44px 34px;
  box-shadow: 0 18px 60px rgba(25, 31, 40, .10);
}

.login-card .brand-mark { margin-bottom: 28px; }
.login-card h1 { margin-bottom: 9px; font-size: 30px; }
.login-description { margin-bottom: 28px; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 9px; }
.login-form label:not(:first-of-type) { margin-top: 8px; }
.login-button { margin-top: 13px; }
.login-footnote { margin-top: 23px; color: #9298a1; font-size: 12px; text-align: center; }
.form-error { margin-bottom: 18px; border-left: 3px solid var(--danger); background: #fff1f0; color: #7a271a; padding: 10px 12px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  border-bottom: 1px solid #243149;
  background: #182235;
  color: #fff;
  padding: 12px 28px;
}

.brand-row, .admin-session, .toolbar-actions, .input-action-row, .modal-heading, .modal-actions, .result-heading {
  display: flex;
  align-items: center;
}

.brand-row { gap: 13px; }
.topbar .eyebrow { color: #9eabc1; }
.admin-session { gap: 16px; color: #cbd2de; }
.topbar .button.ghost { color: #fff; border-color: #66738a; }

.dashboard-shell { width: min(1560px, 100%); margin: 0 auto; padding: 24px 28px 34px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
}

.summary-item { min-height: 96px; border-right: 1px solid var(--line); padding: 20px 22px; }
.summary-item:last-child { border-right: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 13px; }
.summary-item strong { display: block; margin-top: 8px; font-size: 27px; font-weight: 650; }

.workspace-grid { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.panel { border: 1px solid var(--line); background: var(--surface); }
.create-panel { padding: 22px; }
.section-heading { margin-bottom: 22px; }
.stack-form { display: grid; gap: 10px; }
.stack-form label:not(:first-child) { margin-top: 4px; }
.field-help { margin-top: -4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.input-action-row { align-items: stretch; gap: 8px; }
.input-action-row .button { flex: 0 0 auto; }
.two-column-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.created-result { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.result-heading { justify-content: space-between; margin-bottom: 9px; }
.created-result textarea { background: #f5faf7; font-family: Consolas, monospace; font-size: 12px; }

.account-panel { min-width: 0; }
.account-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding: 17px 20px; }
.toolbar-actions { gap: 8px; }
.toolbar-actions input { width: 210px; }
.toolbar-actions select { width: 130px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e6e8eb; padding: 13px 14px; text-align: left; vertical-align: middle; }
th { background: var(--surface-muted); color: #5a626d; font-size: 12px; font-weight: 650; }
td { min-width: 82px; }
td:first-child { min-width: 150px; font-weight: 600; }
td:nth-child(5) { min-width: 172px; }
td:last-child { min-width: 245px; }
tr:hover td { background: #fafaf8; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.status { display: inline-block; border-left: 3px solid var(--line-strong); padding-left: 7px; font-size: 12px; font-weight: 650; }
.status.active { border-color: var(--success); color: var(--success); }
.status.inactive { border-color: var(--danger); color: var(--danger); }
.status.expiring { border-color: var(--warning); color: var(--warning); }
.cell-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.empty-state { padding: 70px 20px; color: var(--muted); text-align: center; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 420px;
  border-left: 4px solid var(--accent);
  background: #182235;
  color: #fff;
  padding: 13px 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .20);
}
.toast.error { border-left-color: #ff6b60; }

.modal {
  width: min(500px, calc(100vw - 30px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 0;
  background: var(--surface);
  box-shadow: 0 25px 80px rgba(20, 28, 38, .24);
}
.modal.wide { width: min(720px, calc(100vw - 30px)); }
.modal::backdrop { background: rgba(21, 29, 40, .42); }
.modal-body { display: grid; gap: 13px; padding: 22px; }
.modal-heading { justify-content: space-between; border-bottom: 1px solid var(--line); margin: -2px -2px 5px; padding-bottom: 15px; }
.modal-subtitle { margin-top: 5px; color: var(--muted); }
.modal-actions { justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 15px; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 25px; line-height: 1; }
.check-row { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.check-row input { width: auto; }
.device-list { display: grid; gap: 9px; max-height: 420px; overflow-y: auto; }
.device-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; border: 1px solid var(--line); padding: 13px; }
.device-name { font-weight: 650; }
.device-meta { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }

.developer-login-page { background: #eef0f4; }
.developer-login-card { border-top-color: #4b3f72; }
.developer-login-card .brand-mark, .developer-topbar .brand-mark { background: #4b3f72; }
.developer-topbar { border-bottom-color: #514777; background: #211d31; }
.super-summary { grid-template-columns: repeat(6, 1fr); }
.super-summary .summary-item:nth-child(4) { border-right: 1px solid var(--line); }
.health-value { font-size: 20px !important; color: var(--muted); }
.health-value.healthy { color: var(--success); }
.system-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.system-panel, .lease-panel { min-width: 0; }
.system-details { margin: 0; padding: 6px 20px 18px; }
.system-details div { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 14px; border-bottom: 1px solid #e6e8eb; padding: 14px 0; }
.system-details div:last-child { border-bottom: 0; }
.system-details dt { color: var(--muted); }
.system-details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.lease-panel td:nth-child(3) { max-width: 220px; overflow-wrap: anywhere; font-family: Consolas, monospace; font-size: 12px; }
.lease-panel td:last-child { min-width: 105px; }

@media (max-width: 1000px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace-grid { grid-template-columns: 1fr; }
  .super-summary { grid-template-columns: repeat(3, 1fr); }
  .super-summary .summary-item:nth-child(3) { border-right: 0; }
  .super-summary .summary-item:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .system-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .admin-session { align-items: flex-end; flex-direction: column; gap: 7px; }
  .dashboard-shell { padding: 14px 12px 24px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .account-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .toolbar-actions input, .toolbar-actions select { width: 100%; }
  .login-card { padding: 34px 26px 28px; }
  .super-summary { grid-template-columns: 1fr 1fr; }
  .super-summary .summary-item:nth-child(3) { border-right: 1px solid var(--line); }
  .super-summary .summary-item:nth-child(even) { border-right: 0; }
  .super-summary .summary-item:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
}
