:root {
  color-scheme: dark;
  --bg: #030711;
  --panel: rgba(8, 20, 38, .86);
  --panel-strong: #0a1a30;
  --line: #183d66;
  --line-bright: #176ec0;
  --blue: #1a9cff;
  --cyan: #66d7ff;
  --text: #edf7ff;
  --muted: #89a4bf;
  --danger: #ff5270;
  --success: #38d6a0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(7, 22, 41, .25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 22, 41, .25) 1px, transparent 1px),
    radial-gradient(circle at 78% -10%, rgba(15, 113, 218, .35), transparent 35%),
    radial-gradient(circle at -10% 70%, rgba(0, 148, 255, .12), transparent 38%),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto, auto;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow, .panel-kicker { margin: 0; color: var(--cyan); font-size: .72rem; font-weight: 800; letter-spacing: .22em; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(37, 99, 154, .55);
  background: rgba(3, 7, 17, .88);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 11px; font-size: .85rem; font-weight: 850; letter-spacing: .11em; text-decoration: none; }
.brand b { color: var(--blue); }
.brand-icon, .brand-mark { display: grid; place-items: center; background: linear-gradient(135deg, #54c9ff, #0067de); color: white; font-weight: 950; font-style: italic; box-shadow: 0 0 28px rgba(0, 140, 255, .42); }
.brand-icon { width: 38px; height: 38px; border-radius: 9px; font-size: .82rem; }
.brand-mark { width: 84px; height: 84px; margin: 0 auto 30px; border-radius: 20px; font-size: 1.8rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.staff-identity { max-width: 180px; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 54px 0 calc(70px + env(safe-area-inset-bottom)); }
.page-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 25px; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 7px 0 0; font-size: clamp(2.1rem, 6vw, 4rem); line-height: 1; letter-spacing: -.055em; }
h2 { margin: 7px 0 10px; font-size: 1.32rem; }

.panel {
  border: 1px solid var(--line);
  border-radius: 19px;
  background: linear-gradient(150deg, rgba(13, 33, 59, .91), var(--panel));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .22), inset 0 1px rgba(255, 255, 255, .025);
}
.login-card { width: min(500px, 100%); margin: 8vh auto 0; padding: clamp(24px, 6vw, 42px); }
.login-card h1 { margin: 10px 0 18px; font-size: clamp(2.2rem, 9vw, 3.5rem); }

.stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 8px; color: #c5d8e9; font-size: .86rem; font-weight: 700; }
.optional { color: var(--muted); font-size: .72rem; font-weight: 500; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid #28547b;
  border-radius: 10px;
  outline: none;
  background: #06101f;
  color: var(--text);
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 156, 255, .17); }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 17px;
  border: 1px solid #2a557c;
  border-radius: 10px;
  background: #0c2037;
  color: white;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.12); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { border-color: #35aaff; background: linear-gradient(135deg, #169fff, #0865db); box-shadow: 0 10px 30px rgba(0, 118, 255, .24); }
.button.secondary { border-color: #2875b3; background: #0d345a; }
.button.ghost { background: rgba(8, 27, 48, .65); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-bottom: 18px; }
.metrics article { display: flex; min-height: 95px; flex-direction: column; justify-content: space-between; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(7, 18, 33, .75); }
.metrics span { color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.metrics strong { color: var(--cyan); font-size: 1.85rem; line-height: 1; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr); gap: 18px; }
.issue-panel, .search-panel { padding: clamp(20px, 4vw, 30px); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; }
.key-result { display: grid; gap: 11px; margin-top: 24px; padding: 17px; border: 1px solid #1e86d5; border-radius: 12px; background: rgba(5, 52, 88, .64); }
.key-result span { color: var(--cyan); font-size: .7rem; font-weight: 850; letter-spacing: .14em; }
.key-result code { color: white; font-size: clamp(.8rem, 2.4vw, 1rem); overflow-wrap: anywhere; }
.key-result p { margin: 0; color: var(--muted); font-size: .78rem; }
.key-result .button { justify-self: start; }
.rule { margin-top: 26px; padding: 18px 0 0; border-top: 1px solid var(--line); }
.rule span { display: block; color: var(--blue); font-size: .67rem; font-weight: 850; letter-spacing: .14em; }
.rule strong { display: block; margin-top: 5px; }
.rule p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }

.licenses-panel { margin-top: 18px; padding: clamp(20px, 4vw, 28px); }
.table-wrap { margin-top: 17px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 830px; border-collapse: collapse; }
th, td { padding: 14px 11px; border-bottom: 1px solid rgba(38, 79, 114, .58); text-align: left; font-size: .81rem; }
th { color: #7795b1; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
td code { color: #8ed7ff; }
.row-actions { white-space: nowrap; }
.mini-button { margin-right: 6px; padding: 7px 9px; border: 1px solid #2f6087; border-radius: 7px; background: #0b2035; color: #ddecf8; cursor: pointer; }
.mini-button.danger { border-color: #7f3041; color: #ff8da1; }
.mini-button:disabled { opacity: .35; cursor: not-allowed; }
.status-pill { display: inline-block; padding: 5px 9px; border-radius: 30px; font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.status-pill.active { background: rgba(36, 190, 137, .13); color: #5ee5b5; }
.status-pill.expired { background: rgba(235, 169, 55, .13); color: #ffc46a; }
.status-pill.revoked { background: rgba(255, 82, 112, .13); color: #ff8399; }
.empty { margin-top: 18px; padding: 30px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }

.notice { position: fixed; z-index: 30; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); max-width: min(390px, calc(100vw - 36px)); padding: 13px 16px; border: 1px solid var(--line-bright); border-radius: 11px; background: #0a2038; box-shadow: 0 18px 50px #000a; color: #dff3ff; font-size: .86rem; }
.notice[data-type="error"] { border-color: #9e3d50; color: #ffabb9; }
.notice[data-type="success"] { border-color: #238665; color: #7eeac4; }

.portal-shell { width: min(760px, calc(100% - 40px)); margin: auto; padding: max(12vh, 70px) 0; text-align: center; }
.portal-shell h1 { margin: 18px 0; font-size: clamp(2.8rem, 9vw, 6.2rem); }
.portal-shell h1 span { color: var(--blue); text-shadow: 0 0 34px rgba(0, 140, 255, .38); }
.lede { max-width: 570px; margin: 0 auto 30px; color: var(--muted); font-size: clamp(1rem, 2vw, 1.18rem); }
.security-note { margin-top: 25px; color: #5f7e9b; font-size: .75rem; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 24px, 1180px); padding-top: 30px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .topbar { min-height: 64px; }
  .brand > span:last-child, .staff-identity { display: none; }
  .page-heading { align-items: center; }
  .page-heading h1 { font-size: 2.5rem; }
  .metrics article { min-height: 84px; padding: 14px; }
  .metrics strong { font-size: 1.5rem; }
  .section-heading { align-items: start; flex-direction: column; gap: 5px; }
}

@media (max-width: 430px) {
  .metrics { gap: 8px; }
  .metrics span { font-size: .62rem; }
  .metrics article { padding: 11px; }
  .login-card { margin-top: 3vh; }
  .page-heading .button { padding-inline: 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  .panel, .metrics article { animation: enter .35s ease both; }
  @keyframes enter { from { opacity: 0; transform: translateY(8px); } }
}
