:root {
  color-scheme: light;
  --ink: #14221c;
  --muted: #617168;
  --line: #d9e3dd;
  --surface: #ffffff;
  --surface-soft: #f2f7f4;
  --page: #eaf2ed;
  --green-900: #0c2b20;
  --green-800: #123d2d;
  --green-700: #176044;
  --green-600: #217a56;
  --green-100: #dff0e7;
  --danger: #a33c3c;
  --danger-soft: #fbe8e8;
  --shadow: 0 18px 48px rgba(16, 51, 37, 0.1);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--page); font-size: 16px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-lockup > span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: var(--green-700); color: white; font-weight: 800; font-size: 14px; }
.brand-lockup div { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 19px; letter-spacing: -0.02em; }
.brand-lockup small { color: var(--green-700); }
.brand-inverse strong { color: white; }
.brand-inverse small { color: #a8cab8; }
.brand-inverse > span { background: #2b8863; border: 1px solid rgba(255, 255, 255, 0.22); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(520px, 0.92fr) minmax(480px, 1.08fr); background: white; }
.login-panel { padding: clamp(44px, 7vw, 98px); display: flex; flex-direction: column; justify-content: space-between; gap: 50px; }
.login-copy { max-width: 580px; }
.eyebrow { margin: 0 0 9px; color: var(--green-600); text-transform: uppercase; letter-spacing: 0.11em; font-size: 12px; font-weight: 800; }
.login-copy h1 { margin: 0; max-width: 560px; font-size: clamp(42px, 5vw, 70px); line-height: 1.04; letter-spacing: -0.055em; }
.login-copy > p:last-child { max-width: 540px; margin: 24px 0 0; color: var(--muted); line-height: 1.75; font-size: 17px; }
.login-panel footer { color: #829087; font-size: 13px; }
.login-aside { overflow: hidden; position: relative; display: grid; place-items: center; padding: 70px; color: white; background: var(--green-900); }
.login-aside::before { content: ""; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(157, 216, 188, 0.22); position: absolute; box-shadow: 0 0 0 100px rgba(255,255,255,0.02), 0 0 0 210px rgba(255,255,255,0.018); }
.security-orbit { position: relative; width: 440px; height: 440px; display: grid; place-items: center; border: 1px solid rgba(172, 222, 198, 0.3); border-radius: 50%; }
.security-orbit strong { width: 162px; height: 162px; display: grid; place-items: center; border-radius: 50%; background: #2c8c66; font-size: 34px; box-shadow: 0 20px 70px rgba(0,0,0,0.28); }
.security-orbit span { position: absolute; padding: 11px 18px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); backdrop-filter: blur(12px); }
.security-orbit span:nth-child(1) { top: 26px; }
.security-orbit span:nth-child(2) { left: -13px; bottom: 107px; }
.security-orbit span:nth-child(3) { right: -8px; bottom: 107px; }
.login-aside blockquote { position: absolute; bottom: 56px; margin: 0; color: #bad2c6; }

.form-stack { max-width: 520px; display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-weight: 700; font-size: 14px; }
input, select { width: 100%; min-height: 46px; border: 1px solid #c9d6cf; border-radius: 9px; background: white; color: var(--ink); padding: 10px 13px; outline: none; }
input:focus, select:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(33, 122, 86, 0.13); }
input[readonly] { color: #6f7c75; background: #eef3f0; }
.button { min-height: 43px; border-radius: 9px; border: 1px solid transparent; padding: 10px 17px; font-weight: 750; }
.button-primary { color: white; background: var(--green-700); }
.button-primary:hover { background: var(--green-800); }
.button-secondary { background: white; border-color: #cfdad4; color: var(--ink); }
.button-wide { min-height: 50px; }
.form-error { margin: 0; padding: 11px 13px; border-radius: 8px; color: #8d2b2b; background: var(--danger-soft); font-weight: 600; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 256px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 25px 17px 20px; background: var(--green-900); }
.sidebar nav { display: grid; gap: 7px; margin-top: 55px; }
.nav-item { width: 100%; min-height: 50px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 10px; padding: 9px 12px; color: #c5d9cf; background: transparent; font-weight: 700; text-align: left; }
.nav-item:hover, .nav-item.active { color: white; background: #214c39; }
.nav-glyph { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; color: #b9d4c6; border: 1px solid #4f7966; font-size: 12px; }
.sidebar-status { margin-top: auto; display: grid; grid-template-columns: 10px 1fr; gap: 4px 9px; padding: 15px; border: 1px solid #345846; border-radius: 11px; color: white; background: #143728; }
.sidebar-status > span { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: #4ec987; box-shadow: 0 0 0 4px rgba(78,201,135,.12); }
.sidebar-status small { grid-column: 2; color: #99baa9; }
.dashboard-link { margin-top: 12px; color: #afc9bc; text-decoration: none; padding: 10px 14px; font-weight: 700; }
.dashboard-link:hover { color: white; }

.workspace { min-width: 0; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 31px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: -0.025em; }
.topbar .eyebrow { margin-bottom: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 15px; }
.current-user { display: flex; align-items: center; gap: 10px; padding-right: 16px; border-right: 1px solid var(--line); }
.current-user > span { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 10px; color: var(--green-800); background: var(--green-100); font-weight: 850; }
.current-user div { display: grid; }
.current-user small { color: var(--muted); }

.view-stack { display: grid; gap: 20px; padding: 24px 30px 36px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: white; box-shadow: 0 8px 24px rgba(17,58,42,.04); }
.summary-grid article { min-height: 142px; display: grid; align-content: center; gap: 8px; padding: 22px 25px; border-right: 1px solid var(--line); }
.summary-grid article:last-child { border-right: 0; }
.summary-grid span { font-weight: 750; }
.summary-grid strong { font-size: 37px; letter-spacing: -0.04em; }
.summary-grid small { color: var(--muted); }
.content-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: 0 12px 30px rgba(17,58,42,.05); }
.panel-header { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 21px 24px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0 0 6px; font-size: 20px; }
.panel-header p { margin: 0; color: var(--muted); }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.search-input { width: 260px; }

.user-list { min-width: 1000px; }
.user-row { display: grid; grid-template-columns: minmax(250px, 1.3fr) 145px minmax(180px, .9fr) minmax(190px, .9fr) 86px 234px; align-items: center; gap: 15px; min-height: 91px; padding: 14px 23px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row:hover { background: #f7faf8; }
.super-admin-row { background: #f4f8f6; }
.user-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { flex: 0 0 auto; width: 43px; height: 43px; display: grid; place-items: center; border-radius: 11px; color: var(--green-800); background: var(--green-100); font-weight: 850; }
.user-identity div, .scope-cell { min-width: 0; display: grid; gap: 4px; }
.user-identity strong, .user-identity small, .scope-cell small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-identity small, .scope-cell small { color: var(--muted); font-size: 12px; }
.role-pill, .status-pill { width: max-content; padding: 7px 10px; border-radius: 999px; color: #345346; background: #eaf2ee; font-size: 12px; font-weight: 800; }
.role-admin { color: #4f3b0c; background: #f5ead0; }
.status-pill.enabled { color: #146541; background: #def2e7; }
.status-pill.disabled { color: #8a3434; background: var(--danger-soft); }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.row-actions button { border: 0; padding: 7px 8px; color: #315244; background: transparent; font-size: 13px; font-weight: 750; }
.row-actions button:hover { background: #e7f0eb; border-radius: 6px; }
.row-actions .danger-link { color: var(--danger); }
.row-actions .success-link { color: var(--green-600); }
.protected-label { color: #69786f; font-size: 12px; }

.audit-list { min-height: 300px; }
.audit-row { display: grid; grid-template-columns: 12px minmax(230px, .7fr) minmax(260px, 1.2fr) 130px; gap: 18px; align-items: center; min-height: 82px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: 0; }
.audit-mark { width: 9px; height: 9px; border-radius: 50%; background: var(--green-600); }
.audit-row div { display: grid; gap: 4px; }
.audit-row small, .audit-row p, .audit-row time { color: var(--muted); }
.audit-row p { margin: 0; }
.audit-row time { font-size: 13px; text-align: right; }
.empty-state { min-height: 260px; display: grid; place-content: center; gap: 7px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); }

.dialog-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(4, 20, 14, 0.58); backdrop-filter: blur(4px); }
.dialog { width: min(820px, 96vw); max-height: 92vh; overflow: auto; border-radius: 15px; background: white; box-shadow: var(--shadow); }
.dialog-small { width: min(520px, 96vw); }
.dialog > header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); background: white; }
.dialog h2 { margin: 0; font-size: 23px; }
.dialog form { display: grid; gap: 19px; padding: 22px 24px 25px; }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: white; font-size: 22px; }
.form-grid.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
fieldset { min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 11px; }
legend { padding: 0 6px; font-weight: 800; }
fieldset > p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.permission-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.permission-option { grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 9px; min-height: 61px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #fafcfb; }
.permission-option:has(input:checked) { border-color: #8bbda5; background: #eff8f3; }
.permission-option input { width: 17px; min-height: 17px; margin: 3px 0 0; accent-color: var(--green-700); }
.permission-option span { min-width: 0; display: grid; gap: 3px; }
.permission-option small { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.toggle-row { grid-template-columns: 42px 1fr; align-items: center; gap: 12px; }
.toggle-row input { width: 42px; min-height: 23px; accent-color: var(--green-700); }
.toggle-row span { display: grid; gap: 3px; }
.toggle-row small { color: var(--muted); font-weight: 500; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.dialog-note { margin: 0; color: var(--muted); }
.toast { position: fixed; z-index: 50; top: 22px; left: 50%; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 9px; color: white; background: #153b2c; box-shadow: var(--shadow); transition: .18s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid article:nth-child(2) { border-right: 0; }
  .summary-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .content-panel { overflow-x: auto; }
}

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .admin-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand-inverse div, .nav-item:not(.active) > :not(.nav-glyph), .sidebar-status, .dashboard-link { display: none; }
  .brand-inverse { justify-content: center; }
  .brand-inverse > span { width: 44px; }
  .nav-item { justify-content: center; padding: 8px; font-size: 0; }
  .nav-glyph { font-size: 12px; }
  .topbar { padding-inline: 18px; }
  .view-stack { padding: 18px; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; }
  .search-input { width: 100%; }
  .permission-grid, .site-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .login-panel { padding: 32px 24px; }
  .login-copy h1 { font-size: 40px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .current-user div { display: none; }
  .form-grid.two-columns { grid-template-columns: 1fr; }
}
