:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17201b;
  background: #f4f6f4;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f4; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #17251e; }
.login-panel { width: min(420px, 100%); background: #fff; border: 1px solid #dfe5e1; border-radius: 8px; padding: 36px; box-shadow: 0 24px 70px rgba(0,0,0,.18); }
.brand-lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.brand-lockup strong { display: block; font-size: 18px; }
.brand-lockup small { display: block; margin-top: 2px; color: #758078; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 7px; background: #36d17f; color: #0c2719; font-weight: 900; }

.form-stack, .dialog-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: #3c4740; font-size: 13px; font-weight: 650; }
label small { color: #7a857e; font-weight: 400; }
input, textarea, select { width: 100%; border: 1px solid #ccd5cf; border-radius: 6px; padding: 10px 12px; color: #17201b; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: #1ba864; box-shadow: 0 0 0 3px rgba(27,168,100,.12); }
textarea { resize: vertical; }
.form-error { min-height: 18px; margin: -4px 0; color: #c93a45; font-size: 13px; }

.primary, .secondary, .danger, .text-button { min-height: 38px; border: 0; border-radius: 6px; padding: 0 15px; font-weight: 700; }
.primary { color: #0c2719; background: #36d17f; }
.primary:hover { background: #2bc574; }
.secondary { color: #334039; background: #e9eeeb; }
.danger { color: #a72c36; background: #fae8e9; }
.text-button { min-height: 32px; padding: 0 9px; color: #247d51; background: transparent; }
.wide { width: 100%; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 232px; display: flex; flex-direction: column; padding: 22px 16px; background: #17251e; color: #fff; }
.sidebar-brand { padding: 0 8px; margin-bottom: 26px; }
.sidebar-brand small { color: #8fa096; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { height: 44px; border: 0; border-radius: 6px; padding: 0 14px; color: #aebbb3; background: transparent; text-align: left; font-weight: 650; }
.nav-item:hover { color: #fff; background: #22342a; }
.nav-item.active { color: #13271b; background: #36d17f; }
.logout { margin-top: auto; height: 40px; border: 1px solid #3b4b42; border-radius: 6px; color: #b8c2bc; background: transparent; }
.main-shell { min-height: 100vh; margin-left: 232px; }
.topbar { height: 88px; display: flex; align-items: center; gap: 16px; padding: 0 32px; border-bottom: 1px solid #dde4df; background: #fff; }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 4px 0 0; color: #758078; font-size: 13px; }
.health { display: flex; align-items: center; gap: 7px; margin-left: auto; color: #536058; font-size: 13px; }
.health span { width: 8px; height: 8px; border-radius: 50%; background: #22b96b; box-shadow: 0 0 0 4px #ddf6e8; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 6px; color: #48544d; background: #eef2ef; font-size: 20px; }
#menu-toggle { display: none; }
.content { max-width: 1320px; padding: 28px 32px 60px; }
.view { display: none; }
.view.active { display: block; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric { min-height: 116px; padding: 20px; border: 1px solid #dde4df; border-radius: 7px; background: #fff; }
.metric span { color: #748078; font-size: 13px; }
.metric strong { display: block; margin-top: 12px; font-size: 28px; line-height: 1; }
.metric small { display: block; margin-top: 10px; color: #839087; }
.section-block { margin-top: 18px; padding: 22px; border: 1px solid #dde4df; border-radius: 7px; background: #fff; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.section-heading h2, .dialog-heading h2 { margin: 0; font-size: 17px; }
.section-heading p, .dialog-heading p { margin: 5px 0 0; color: #7a857e; font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.summary-item { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid #edf0ee; }
.summary-item span { color: #758078; }
.summary-item strong { max-width: 65%; text-align: right; overflow-wrap: anywhere; }

.table-wrap { overflow: auto; border: 1px solid #dde4df; border-radius: 7px; background: #fff; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 16px; border-bottom: 1px solid #e8ece9; text-align: left; font-size: 13px; }
th { color: #6c776f; background: #f8faf8; font-size: 12px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td strong { font-size: 13px; }
td small { display: block; margin-top: 4px; color: #89938d; }
.actions-col { text-align: right; }
td.actions { text-align: right; }
.extend-license { width: 116px; height: 32px; padding: 0 8px; font-size: 12px; vertical-align: middle; }
.badge { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 0 9px; font-size: 12px; font-weight: 700; }
.badge.ok { color: #11653d; background: #dcf5e7; }
.badge.off { color: #8e343b; background: #f9e2e4; }
.badge.warn { color: #875716; background: #faedce; }
.badge.dedicated { color: #28538a; background: #e2ebf7; }
.badge.shared { color: #755315; background: #f5e9c9; }
.badge.idle { color: #59645d; background: #e9eeeb; }
.empty { padding: 32px !important; color: #879189; text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.filter-row { display: flex; gap: 10px; margin-bottom: 14px; }
.filter-row input { max-width: 340px; }
.filter-row select { width: 140px; }

.settings-form { max-width: 820px; padding: 24px; border: 1px solid #dde4df; border-radius: 7px; background: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.toggle-line { display: flex; align-items: center; gap: 9px; }
.toggle-line input { width: 17px; height: 17px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 22px; }

dialog { width: min(620px, calc(100% - 28px)); border: 0; border-radius: 8px; padding: 0; box-shadow: 0 28px 80px rgba(14,31,21,.24); }
dialog::backdrop { background: rgba(14,26,19,.58); }
.dialog-form { padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: min(360px, calc(100% - 48px)); border-radius: 6px; padding: 12px 16px; color: #fff; background: #17251e; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a9323c; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-shell { margin-left: 0; }
  #menu-toggle { display: grid; }
}

@media (max-width: 620px) {
  .topbar { height: 78px; padding: 0 16px; }
  .topbar p, .health { display: none; }
  .content { padding: 20px 16px 48px; }
  .metrics, .summary-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .section-heading { align-items: flex-start; }
  .section-heading .primary { flex: 0 0 auto; }
  .heading-actions { width: 100%; flex-wrap: wrap; }
  #view-routes .section-heading { flex-direction: column; }
  .filter-row { flex-direction: column; }
  .filter-row input, .filter-row select { max-width: none; width: 100%; }
  .login-panel { padding: 28px 22px; }
}
