:root {
  --navy-950: #061326;
  --navy-900: #071a34;
  --navy-800: #0b284d;
  --navy-700: #123b69;
  --blue: #087cff;
  --blue-bright: #22a4ff;
  --cyan: #4fd1ff;
  --ink: #10223a;
  --muted: #66768c;
  --line: #dce5ef;
  --surface: #ffffff;
  --background: #f3f6fa;
  --good: #16a36a;
  --warning: #e58b11;
  --danger: #dd3f4b;
  --shadow: 0 18px 48px rgba(9, 35, 67, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 6px;
  color: #8a99aa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.electric { color: var(--blue); }
.muted { color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.good { background: var(--good); box-shadow: 0 0 0 4px rgba(22, 163, 106, 0.12); }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.2fr) minmax(420px, .8fr); }
.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(52px, 8vw, 120px);
  color: white;
  background:
    radial-gradient(circle at 78% 18%, rgba(34, 164, 255, .38), transparent 24%),
    linear-gradient(145deg, var(--navy-950), var(--navy-800));
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 500px;
  height: 500px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  right: -260px;
  bottom: -210px;
  box-shadow: 0 0 0 72px rgba(255,255,255,.025), 0 0 0 144px rgba(255,255,255,.018);
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px 12px 18px 12px;
  overflow: hidden;
  padding: 3px;
  background: white;
  box-shadow: 0 10px 30px rgba(8, 124, 255, .35);
}
.brand-mark img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: contain; }
.brand-mark.large { width: 72px; height: 72px; margin-bottom: 54px; padding: 5px; border-radius: 20px 20px 30px 20px; }
.login-brand h1 { max-width: 720px; margin: 0; font-size: clamp(42px, 5.4vw, 78px); line-height: .98; letter-spacing: -.045em; }
.login-brand .eyebrow { color: var(--cyan); }
.login-copy { max-width: 600px; margin: 28px 0 0; color: #c7d5e5; font-size: 18px; }
.signal-grid { position: absolute; left: clamp(52px, 8vw, 120px); bottom: 54px; display: flex; gap: 8px; align-items: end; }
.signal-grid span { width: 7px; height: 10px; border-radius: 4px; background: rgba(79, 209, 255, .4); }
.signal-grid span:nth-child(2) { height: 16px; }
.signal-grid span:nth-child(3) { height: 24px; }
.signal-grid span:nth-child(4) { height: 34px; background: var(--cyan); }
.signal-grid span:nth-child(5) { height: 20px; }
.signal-grid span:nth-child(6) { height: 12px; }
.login-panel { display: grid; place-items: center; padding: 50px; background: white; }
.login-card { width: min(430px, 100%); }
.login-card h2 { margin: 0; font-size: 32px; letter-spacing: -.03em; }
.login-card > .muted { margin: 8px 0 32px; }
.mobile-brand { display: none; }
label { display: grid; gap: 7px; color: #42536a; font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid #cad6e3;
  border-radius: 10px;
  outline: none;
  background: white;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(8, 124, 255, .11); }
.login-card label + label { margin-top: 18px; }
.form-error { min-height: 20px; margin: 12px 0; color: var(--danger); font-size: 13px; }
.button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { color: white; background: linear-gradient(135deg, var(--blue), #005ac8); box-shadow: 0 10px 24px rgba(8, 124, 255, .22); }
.button.secondary { color: var(--navy-800); border: 1px solid var(--line); background: white; }
.button.full { width: 100%; }
.secure-note { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 22px 0 0; color: var(--muted); font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 248px;
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  color: white;
  background: linear-gradient(180deg, var(--navy-950), #081c36 68%, #0b2b52);
}
.app-brand { display: flex; align-items: center; gap: 12px; padding: 0 9px; color: white; text-decoration: none; }
.app-brand strong { display: block; font-size: 20px; letter-spacing: .06em; }
.app-brand small { display: block; margin-top: -2px; color: var(--cyan); font-size: 9px; letter-spacing: .2em; }
.sidebar nav { display: grid; gap: 6px; margin-top: 54px; }
.nav-link { display: flex; align-items: center; gap: 13px; padding: 13px 14px; border-radius: 10px; color: #9fb3ca; text-decoration: none; font-size: 14px; font-weight: 700; }
.nav-link span { color: #547493; font-size: 10px; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(34, 164, 255, .13); }
.nav-link.active span { color: var(--cyan); }
.sidebar-foot { margin-top: auto; }
.service-state { display: flex; align-items: center; gap: 12px; padding: 16px 11px; border-top: 1px solid rgba(255,255,255,.08); border-bottom: 1px solid rgba(255,255,255,.08); }
.service-state strong, .service-state small { display: block; }
.service-state strong { font-size: 12px; }
.service-state small { margin-top: 2px; color: #7e9ab7; font-size: 10px; }
.text-button { width: 100%; padding: 16px 11px 0; color: #90a8c1; border: 0; text-align: left; background: transparent; cursor: pointer; font-size: 12px; }
.text-button:hover { color: white; }

.main-content { grid-column: 2; min-width: 0; padding: 0 36px 70px; }
.topbar { min-height: 92px; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.user-area { margin-left: auto; display: flex; align-items: center; gap: 12px; text-align: right; }
.user-area strong, .user-area small { display: block; }
.user-area strong { font-size: 12px; }
.user-area small { color: var(--muted); font-size: 10px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy-800); font-size: 11px; font-weight: 900; }
.menu-button { display: none; }
.content-section { scroll-margin-top: 28px; }
.hero-section { display: flex; justify-content: space-between; align-items: end; padding: 42px 0 25px; }
.hero-section h2 { margin: 0; font-size: 36px; letter-spacing: -.04em; }
.hero-section .muted { margin: 8px 0 0; }
.warning-banner { display: flex; align-items: center; gap: 14px; margin: 0 0 20px; padding: 15px 18px; border: 1px solid #ffd9a3; border-radius: 12px; background: #fff8eb; }
.warning-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--warning); font-weight: 900; }
.warning-banner strong { font-size: 13px; }
.warning-banner p { margin: 2px 0 0; color: #8b6228; font-size: 12px; }
.warning-banner a { margin-left: auto; color: #a35b00; font-size: 12px; font-weight: 800; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card { position: relative; overflow: hidden; min-height: 148px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 26px rgba(9,35,67,.04); }
.metric-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: #b8c7d8; }
.metric-card.accent::before { background: var(--blue); }
.metric-card.danger::before { background: var(--danger); }
.metric-card span, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: 12px 0 4px; font-size: 42px; line-height: 1; letter-spacing: -.05em; }
.metric-card small { color: #8a99aa; font-size: 10px; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.panel-card, .table-section { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 26px rgba(9,35,67,.04); }
.action-card { padding: 24px; }
.card-heading, .section-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.card-heading h3, .section-heading h2 { margin: 0; letter-spacing: -.025em; }
.number-chip { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--blue); background: #edf6ff; font-size: 10px; font-weight: 900; }
.compact-form { display: grid; gap: 14px; margin-top: 22px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compact-form .button { justify-self: start; margin-top: 2px; }
.table-section { margin-top: 24px; padding: 24px; }
.section-heading { align-items: center; margin-bottom: 18px; }
.section-heading h2 { font-size: 22px; }
.count-pill { padding: 7px 10px; border-radius: 999px; color: var(--navy-700); background: #edf3f9; font-size: 10px; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 12px; color: #7a8da2; border-bottom: 1px solid var(--line); text-align: left; font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
td { padding: 14px 12px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfe; }
.empty-row { padding: 30px; color: var(--muted); text-align: center; }
.table-primary { display: block; color: var(--ink); font-weight: 800; }
.table-secondary { display: block; margin-top: 3px; color: #8291a3; font-size: 10px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.protected, .badge.active { color: #087a4d; background: #e8f7f0; }
.badge.warning { color: #a25b00; background: #fff3dd; }
.badge.offline, .badge.inactive { color: #7f8a99; background: #edf1f4; }
.badge.expired { color: #b52e3a; background: #fdebed; }
.row-actions { white-space: nowrap; }
.row-action { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; font-size: 10px; font-weight: 800; }
.row-action + .row-action { margin-left: 5px; }
.row-action.edit { color: var(--navy-700); }
.row-action.delete { color: var(--danger); }
.row-action:hover { background: #f2f7fc; }
.row-action:disabled { opacity: .45; cursor: wait; }

.license-dialog { width: min(520px, calc(100% - 32px)); padding: 36px; border: 0; border-radius: 18px; color: var(--ink); box-shadow: var(--shadow); text-align: center; }
.license-dialog::backdrop { background: rgba(2, 12, 26, .7); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: 0; border-radius: 8px; cursor: pointer; }
.success-mark { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 50%; color: white; background: var(--good); font-size: 13px; font-weight: 900; }
.license-dialog h2 { margin: 0; font-size: 28px; }
.generated-key { margin: 24px 0 16px; padding: 17px 12px; border: 1px dashed var(--blue); border-radius: 10px; color: var(--navy-800); background: #f0f7ff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(13px, 3vw, 18px); font-weight: 900; letter-spacing: .04em; word-break: break-all; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 380px; padding: 13px 16px; border-radius: 10px; color: white; background: var(--navy-900); box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); pointer-events: none; transition: .2s; font-size: 12px; font-weight: 700; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.editor-dialog { width: min(620px, calc(100% - 32px)); padding: 30px; border: 0; border-radius: 18px; color: var(--ink); box-shadow: var(--shadow); }
.editor-dialog::backdrop { background: rgba(2, 12, 26, .7); backdrop-filter: blur(4px); }
.editor-dialog form { display: grid; gap: 18px; }
.dialog-heading { position: relative; display: flex; justify-content: space-between; align-items: start; margin-bottom: 4px; }
.dialog-heading h2 { margin: 0; font-size: 28px; }
.dialog-heading .dialog-close { position: static; flex: 0 0 auto; }
.checkbox-field { display: flex; align-items: center; gap: 10px; }
.checkbox-field input { width: 18px; min-height: 18px; height: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .login-brand { padding: 60px; }
}

@media (max-width: 820px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 28px; background: linear-gradient(180deg, #eef5fb, white); }
  .mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 54px; color: var(--navy-800); font-weight: 900; }
  .app-shell { display: block; }
  .sidebar { width: min(290px, 86vw); transform: translateX(-105%); transition: transform .22s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 0 18px 55px; }
  .topbar { min-height: 78px; }
  .menu-button { display: inline-block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; }
  .topbar .eyebrow, .topbar h1, .user-area div { display: none; }
  .user-area { margin-left: auto; }
  .action-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .hero-section { align-items: start; gap: 20px; }
  .hero-section h2 { font-size: 29px; }
  .hero-section .button { min-width: 44px; padding: 0 12px; font-size: 0; }
  .hero-section .button::after { content: "↻"; font-size: 20px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 126px; padding: 17px; }
  .metric-card strong { font-size: 34px; }
  .metric-card span { font-size: 10px; }
  .field-row { grid-template-columns: 1fr; }
  .table-section, .action-card { padding: 18px; }
  .warning-banner a { display: none; }
}
