:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17223a;
  background: #f4f6fa;
  font-synthesis: none;
  --muted: #526179;
  --border: #dce3ed;
  --accent: #2853ae;
  --accent-hover: #1d438f;
  --ok-bg: #e9f7f0;
  --ok-fg: #146348;
  --warn-bg: #fff5e5;
  --warn-fg: #9a5504;
  --danger-bg: #fdeeee;
  --danger-fg: #a12530;
  --neutral-bg: #edf1f7;
  --neutral-fg: #4b5a73;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding-bottom: 48px; }
button, input, select { font: inherit; }
p, h1, h2, h3, dl, dd { margin: 0; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.page-width {
  width: min(calc(100% - 40px), 1200px);
  margin-inline: auto;
}

/* Topbar */
.topbar { background: #14213b; color: #fff; }
.topbar-inner {
  min-height: 62px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 8px;
}
.brand-wrap { display: flex; align-items: center; gap: 10px; }
.brand { font-size: 1rem; letter-spacing: .04em; }
.env-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: #243860;
  color: #cddcf7;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.local { font-size: .82rem; color: #c3cfe4; }
.top-btn {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid #354c79;
  background: #1f3359;
  color: #edf3ff;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.top-btn:hover { background: #294272; }
.top-btn-ghost { background: transparent; border-color: #3a517c; }

/* Login view */
.login-shell {
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(100%, 420px);
  padding: 32px;
}
.login-card h1 { font-size: 1.55rem; margin-bottom: 8px; }
.login-card .hint { margin-bottom: 22px; }
.full-btn, .full-width { width: 100%; }

/* Intro & tabs */
.intro { padding-block: 28px 20px; }
.intro-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
}
.intro h1 { font-size: clamp(1.55rem, 3.2vw, 2.1rem); letter-spacing: -.03em; line-height: 1.15; }
.intro p { margin-top: 8px; color: var(--muted); font-size: .92rem; line-height: 1.6; }

.mode-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #e9eef7;
  gap: 4px;
}
.mode-tab {
  min-height: 36px;
  padding: 6px 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-tab[aria-selected="true"] {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 8px #1c396118;
}
.mode-tab:hover:not([aria-selected="true"]) { color: #17223a; }

/* Layout */
.panel-stack { display: grid; gap: 18px; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 22px #1c396108;
}
.form-card { padding: 24px 28px; }
.card h2 { margin-bottom: 18px; font-size: 1.12rem; line-height: 1.35; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 { margin-bottom: 0; }

/* Dashboard stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 15px 17px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.stat-card:hover { border-color: #9cb4dc; transform: translateY(-1px); box-shadow: 0 6px 16px #1c396110; }
.stat-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px #2853ae26; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.7rem; line-height: 1.15; letter-spacing: -.02em; }
.stat-sub { font-size: .74rem; color: var(--muted); }
.stat-ok .stat-value { color: var(--ok-fg); }
.stat-warn .stat-value { color: var(--warn-fg); }
.stat-danger .stat-value { color: var(--danger-fg); }
.stat-muted .stat-value { color: var(--neutral-fg); }

/* Toolbar */
.toolbar-card { padding: 14px 18px; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.search-input {
  flex: 1 1 280px;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid #cdd7e7;
  border-radius: 8px;
  background: #fcfdff;
}
.select-input {
  height: 40px;
  padding: 7px 10px;
  border: 1px solid #cdd7e7;
  border-radius: 8px;
  background: #fcfdff;
  color: inherit;
}
.toolbar-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* Enterprise cards */
.enterprise-list { display: grid; gap: 14px; }
.empty-state {
  padding: 46px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state h3 { color: #17223a; margin-bottom: 8px; font-size: 1.05rem; }
.empty-state p { font-size: .88rem; margin-bottom: 16px; }

.ent-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px #1c396107;
}
.ent-card.is-disabled { opacity: .82; border-color: #d6c5c8; }
.ent-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding: 16px 20px;
  background: #f9fbfe;
  border-bottom: 1px solid #e8edf5;
}
.ent-title-group { display: grid; gap: 6px; min-width: 0; }
.ent-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ent-name { font-size: 1.04rem; font-weight: 700; color: #132038; }
.ent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: .8rem;
  color: var(--muted);
}
.ent-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.lic-table-wrap { overflow-x: auto; }
.lic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.lic-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: .75rem;
  font-weight: 650;
  color: var(--muted);
  background: #fcfdff;
  border-bottom: 1px solid #edf1f7;
  white-space: nowrap;
}
.lic-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f3f8;
  vertical-align: top;
}
.lic-table tr:last-child td { border-bottom: 0; }
.lic-empty-row { padding: 18px 20px; color: var(--muted); font-size: .84rem; }

.cell-stack { display: grid; gap: 4px; }
.cell-sub { font-size: .74rem; color: var(--muted); }
.cred-mini { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cred-mini code { font-size: .76rem; word-break: break-all; }

.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 650;
  white-space: nowrap;
}
.badge-active { background: var(--ok-bg); color: var(--ok-fg); }
.badge-expiring { background: var(--warn-bg); color: var(--warn-fg); }
.badge-expired, .badge-superseded { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge-revoked, .badge-disabled, .badge-enterprise_disabled { background: var(--danger-bg); color: var(--danger-fg); }
.badge-online { background: #e8f0fe; color: #1d4ea8; }
.badge-offline { background: #f1f3f7; color: #526179; }

/* Buttons */
.primary, .download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-size: .88rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.primary:hover:not(:disabled), .download:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .6; cursor: default; }

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #c6d2e4;
  border-radius: 8px;
  background: #fff;
  color: #1f3359;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
}
.secondary:hover { background: #f2f6fc; }

.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 15px;
  border: 0;
  border-radius: 8px;
  background: #c12b38;
  color: #fff;
  font-size: .88rem;
  font-weight: 650;
  cursor: pointer;
}
.danger-btn:hover { background: #a1202b; }

.mini-btn {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid #ced8e8;
  background: #fff;
  color: #203457;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn:hover { background: #eef4fc; border-color: #9cb4dc; }
.mini-btn-primary { background: #edf3fe; border-color: #b7cef7; color: #1b4498; }
.mini-btn-warn { color: var(--warn-fg); border-color: #f0d09e; background: #fffbf4; }
.mini-btn-warn:hover { background: var(--warn-bg); }
.mini-btn-danger { color: var(--danger-fg); border-color: #ecc0c4; background: #fff9f9; }
.mini-btn-danger:hover { background: var(--danger-bg); }

.chip-btn {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #cdd7e7;
  background: #f8faff;
  color: #243b68;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn:hover { background: #e8f0fe; border-color: #8fb1eb; }

/* Form fields */
.field { display: grid; gap: 6px; min-width: 0; }
.field + .field, .field + .deadline, .deadline + .field, .sub-box + .deadline { margin-top: 15px; }
.field label, .advanced summary { font-size: .87rem; font-weight: 650; }
.optional { margin-inline-start: 4px; color: var(--muted); font-size: .76rem; font-weight: 400; }
.field input[type="text"],
.field input[type="password"],
.field input[type="url"],
.field input[type="date"],
.field input[type="time"] {
  width: 100%;
  min-width: 0;
  height: 41px;
  padding: 8px 11px;
  color: inherit;
  background: #fcfdff;
  border: 1px solid #cdd7e7;
  border-radius: 8px;
}
.hint { color: var(--muted); font-size: .8rem; line-height: 1.55; }
.deadline { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 15px; }
.deadline .field { margin-top: 0; }
.sub-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #e1e8f3;
  border-radius: 10px;
  background: #f9fbff;
}
.quick-durations { display: flex; flex-wrap: wrap; gap: 7px; }
.online-toggle-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #d4e2f7;
  border-radius: 10px;
  background: #f5f9ff;
  display: grid;
  gap: 8px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
}
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--accent); }
.advanced { margin-top: 16px; padding: 12px 0; border-block: 1px solid var(--border); }
.advanced summary { width: fit-content; cursor: pointer; }
.advanced .field { margin-block: 12px 2px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }
.filename { font-size: .8rem; color: var(--muted); }
.status { margin-top: 12px; font-size: .84rem; line-height: 1.55; }
.status[data-error] { color: var(--danger-fg); }

/* Result & verify boxes */
.result { margin-top: 20px; padding: 16px; border: 1px solid #badbd0; border-radius: 10px; background: #f0faf5; }
.result h3 { color: #155b45; font-size: 1rem; }
.result p { margin-top: 5px; color: #355e51; font-size: .84rem; overflow-wrap: anywhere; }
.result dl { margin-top: 12px; }
.result dt { color: #355e51; font-size: .77rem; }
.result dd { font-size: .82rem; margin-block: 4px 10px; overflow-wrap: anywhere; }
.cred-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.copy-chip {
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid #9ccab9;
  border-radius: 6px;
  background: #fff;
  color: #155b45;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
}
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }

.dropzone {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 20px;
  border: 2px dashed #c4d1e4;
  border-radius: 12px;
  background: #f9fbff;
  text-align: center;
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: #eff5ff; }
.dropzone-title { font-weight: 650; font-size: .95rem; }
.verify-result { margin-top: 20px; padding: 18px; border: 1px solid #badbd0; border-radius: 12px; background: #f2fbf7; }
.verify-result[data-state="expired"], .verify-result[data-state="invalid"] { border-color: #ebd0b0; background: #fff9f0; }
.verify-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.verify-badge { padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: #d6f0e4; color: #135a43; }
.verify-summary { margin-top: 8px; font-size: .86rem; color: #355e51; }
.inspect-grid { margin-top: 14px; display: grid; gap: 10px; }
.inspect-item { padding: 9px 11px; border: 1px solid #dce6e1; border-radius: 8px; background: #fff; }
.inspect-item dt { font-size: .75rem; color: var(--muted); }
.inspect-item dd { margin-top: 4px; font-size: .84rem; overflow-wrap: anywhere; }
.batch-result { margin-top: 18px; display: grid; gap: 8px; }
.batch-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fcfdff;
  font-size: .84rem;
}

/* Sidebar guide */
.handoff { padding: 24px; }
.handoff h3 { margin-top: 14px; font-size: .9rem; }
.handoff p { margin-top: 7px; color: var(--muted); font-size: .84rem; line-height: 1.65; }
.command { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #f7f9fc; }
.command span { display: block; color: var(--muted); font-size: .74rem; }
.command code { display: block; margin-top: 4px; font-size: .81rem; overflow-wrap: anywhere; }
.delivery { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Audit logs */
.audit-list { display: grid; gap: 8px; }
.audit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 11px 14px;
  border: 1px solid #e7ecf4;
  border-radius: 9px;
  background: #fcfdff;
  font-size: .84rem;
}
.audit-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.audit-time { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* Dialog modals */
.modal {
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  width: min(calc(100vw - 32px), 520px);
  box-shadow: 0 24px 60px #0d1a3345;
}
.modal::backdrop { background: #0f1b3380; backdrop-filter: blur(2px); }
.modal-card {
  background: #fff;
  padding: 22px 24px;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: grid;
  gap: 12px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 1.08rem; }
.icon-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.warn-box {
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid #f0cfd2;
  background: var(--danger-bg);
  color: var(--danger-fg);
  font-size: .83rem;
  line-height: 1.55;
}

/* Toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999;
  padding: 11px 16px;
  border-radius: 10px;
  background: #14213b;
  color: #fff;
  font-size: .86rem;
  font-weight: 500;
  box-shadow: 0 12px 28px #0d1a3335;
}

:focus-visible { outline: 2px solid #315dc4; outline-offset: 2px; }

@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-width { width: calc(100% - 24px); }
  .deadline { grid-template-columns: 1fr; }
  .form-card { padding: 18px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
