:root {
  --ink: #07182c;
  --muted: #5c6b7d;
  --line: #d9e1ea;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --nav: #10243a;
  --nav-2: #183853;
  --maple: #c94b32;
  --maple-dark: #9f321f;
  --teal: #126c72;
  --amber: #b56b13;
  --green: #21704b;
  --blue: #1f5f9e;
  --shadow: 0 18px 38px rgba(17, 35, 56, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; }

body.locked { overflow: hidden; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 28px;
  color: #fff;
  background:
    linear-gradient(115deg, rgba(7,24,44,0.97), rgba(16,36,58,0.91) 48%, rgba(23,73,79,0.88)),
    radial-gradient(circle at 72% 18%, rgba(201,75,50,0.28), transparent 30%);
}

body:not(.locked) .login-screen { display: none; }
body.locked .app-shell { display: none; }

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--maple);
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(0,0,0,0.24);
}
.login-brand strong, .login-brand span { display: block; }
.login-brand span { color: #bfd0dc; font-size: 13px; margin-top: 2px; }

.login-hero {
  width: min(1120px, 100%);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 430px);
  gap: 42px;
  align-items: center;
}
.login-copy h1 {
  max-width: 720px;
  color: #fff;
  font-size: 54px;
  line-height: 1.02;
  font-weight: 850;
}
.login-copy p:not(.eyebrow) {
  max-width: 600px;
  margin: 18px 0 0;
  color: #d6e2ea;
  font-size: 18px;
  line-height: 1.55;
}
.login-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 150px));
  gap: 12px;
  margin-top: 30px;
}
.login-proof div {
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255,255,255,0.08);
}
.login-proof strong { display: block; font-size: 28px; }
.login-proof span { color: #bfccd7; font-size: 12px; font-weight: 750; }

.login-card {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 24px;
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  box-shadow: 0 34px 80px rgba(0,0,0,0.34);
}
.login-card h2 { font-size: 25px; }
.login-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}
.login-check input {
  width: 17px;
  height: 17px;
  margin: 0;
}
.login-submit {
  width: 100%;
  border-color: var(--maple);
  background: var(--maple);
  color: #fff;
  padding: 12px 14px;
}
.login-error {
  min-height: 18px;
  margin: 0;
  color: #9f321f;
  font-size: 13px;
  font-weight: 800;
}
.login-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #d6e2ea;
}
.login-footer span {
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background:
    linear-gradient(180deg, #07182c 0%, #0b2134 46%, #0d2b39 100%);
  color: #fff;
  padding: 16px 12px;
  border-right: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.03);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 16px;
  margin-bottom: 10px;
  border: 1px solid rgba(241,182,74,0.25);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--maple);
  font-weight: 800;
}

.brand strong, .brand span { display: block; }
.brand span { color: #b9c8d8; font-size: 12px; margin-top: 2px; }

.search-box { display: block; margin: 0 2px 12px; color: #c9d6e5; font-size: 12px; }
.search-box input {
  width: 100%;
  margin-top: 7px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.07);
  color: #fff;
  border-radius: 8px;
  padding: 12px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.search-box input::placeholder { color: #93a9bd; }

.menu-list { display: grid; gap: 7px; padding-bottom: 20px; }
.menu-group {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0,0,0,0.11);
}
.menu-group.active {
  border-color: rgba(83,208,197,0.38);
  background: rgba(24,56,83,0.64);
}
.menu-section {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #dce7f2;
  text-align: left;
  padding: 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.menu-section:hover, .menu-section.active { background: rgba(255,255,255,0.06); color: #fff; }
.menu-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,0.09);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.menu-name { min-width: 0; line-height: 1.2; }
.menu-name strong {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 760;
  font-size: 13px;
}
.menu-name em {
  display: block;
  margin-top: 3px;
  color: #8fa8bb;
  font-style: normal;
  font-size: 11px;
  font-weight: 650;
}
.menu-meta {
  display: grid;
  grid-template-columns: auto 18px;
  gap: 7px;
  align-items: center;
}
.menu-count {
  min-width: 24px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 999px;
  color: #cbd9e7;
  font-size: 11px;
  font-weight: 850;
  padding: 3px 7px;
  text-align: center;
}
.menu-chevron {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.06);
}
.menu-chevron::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid #a7bbc9;
  border-bottom: 2px solid #a7bbc9;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 160ms ease;
}
.menu-group.open .menu-chevron::before {
  transform: rotate(225deg) translate(-1px, -1px);
}
.menu-meta.tone-1 .menu-count { border-color: rgba(83,208,197,0.24); color: #7eeee5; }
.menu-meta.tone-2 .menu-count { border-color: rgba(241,182,74,0.28); color: #f1c46a; }
.menu-meta.tone-3 .menu-count { border-color: rgba(119,171,255,0.28); color: #9dc1ff; }
.menu-meta.tone-4 .menu-count { border-color: rgba(109,210,146,0.28); color: #92e2b3; }
.menu-meta.tone-5 .menu-count { border-color: rgba(233,133,111,0.3); color: #f0a18e; }
.menu-meta.tone-6 .menu-count { border-color: rgba(186,145,255,0.3); color: #c9adff; }
.menu-meta.tone-7 .menu-count { border-color: rgba(255,255,255,0.22); color: #f2f6fa; }
.menu-links {
  display: grid;
  gap: 2px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 8px 0 48px;
  transition: max-height 220ms ease, opacity 160ms ease, padding 160ms ease;
}
.menu-group.open .menu-links {
  max-height: 720px;
  opacity: 1;
  padding-bottom: 10px;
}
.menu-link {
  min-height: 28px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border-radius: 6px;
  color: #b9c8d8;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.2;
}
.menu-link span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #53d0c5;
  opacity: 0.78;
}
.menu-link strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}
.menu-link:hover,
.menu-link.active {
  color: #fff;
  background: rgba(83,208,197,0.11);
}
.menu-link.active span {
  background: #f1b64a;
  opacity: 1;
}

.workspace { min-width: 0; padding: 24px; }

.topbar {
  min-height: 84px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.session-card {
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
}
.session-card strong { display: block; font-size: 14px; }
.session-card span { display: block; color: var(--muted); margin-top: 3px; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--maple-dark);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 27px; line-height: 1.16; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 15px; }

.selectors {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 10px;
  width: min(760px, 100%);
  align-items: end;
}
label { color: var(--muted); font-size: 12px; font-weight: 700; }
select, input, textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}
textarea { resize: vertical; }

.context-strip, .dashboard-grid, .module-layout { margin-bottom: 16px; }
.context-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.context-chip, .metric-card, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.context-chip { padding: 12px; min-height: 70px; }
.context-chip span, .metric-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.context-chip strong, .metric-card strong { display: block; margin-top: 5px; font-size: 16px; line-height: 1.2; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  gap: 12px;
}
.metric-card { padding: 16px; min-height: 96px; }
.metric-card strong { font-size: 26px; }
.metric-card:nth-child(2) strong { color: var(--teal); }
.metric-card:nth-child(3) strong { color: var(--amber); }
.metric-card:nth-child(4) strong { color: var(--green); }
.metric-card:nth-child(5) strong { color: var(--blue); }

.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
}
.bottom-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.panel { min-width: 0; padding: 16px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head.compact { align-items: center; }
.panel-actions, .form-actions, .record-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
  cursor: pointer;
}
button.primary, .form-actions button:first-child { background: var(--maple); border-color: var(--maple); color: #fff; }
button.danger { color: #a12b20; border-color: #e7b9b2; }
button:disabled { opacity: 0.48; cursor: not-allowed; }

.notice {
  display: none;
  margin: 14px 0 0;
  padding: 11px 12px;
  border-radius: 8px;
  background: #fff4e4;
  border: 1px solid #f0cf99;
  color: #6f430c;
  font-weight: 700;
  font-size: 13px;
}
.notice.show { display: block; }

.link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}
.module-link {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
  display: block;
}
.module-link:hover, .module-link.active { border-color: #8bb7ba; background: #eef8f7; }
.module-link strong { display: block; font-size: 13px; line-height: 1.25; }
.module-link span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }

.special-module {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.special-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.special-card p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.core-console {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}
.core-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 260px);
  gap: 12px;
  align-items: start;
}
.core-head h3 { line-height: 1.35; }
.core-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px minmax(180px, 0.7fr) auto;
  gap: 9px;
  margin-top: 12px;
}
.core-form input, .core-form select { margin-top: 0; }
.core-table-wrap {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.core-table-wrap table { min-width: 880px; }

.record-form { display: grid; gap: 11px; padding-top: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.table-wrap { overflow: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: #fff; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0; background: #f5f7fa; }
tr:last-child td { border-bottom: 0; }
.tag {
  display: inline-block;
  border-radius: 6px;
  padding: 4px 7px;
  background: #edf5f3;
  color: #155c51;
  font-weight: 800;
  font-size: 12px;
}
.tag.warn { background: #fff2dd; color: #7b4707; }
.tag.lock { background: #feecea; color: #8c251c; }
.muted { color: var(--muted); }

.api-panel, .audit-panel { display: grid; gap: 9px; padding-top: 14px; }
.endpoint, .audit-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfe;
  font-size: 13px;
}
.endpoint code { display: block; margin-top: 5px; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-row strong { display: block; }
.audit-row span { color: var(--muted); font-size: 12px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 310px minmax(0, 1fr); }
  .login-hero { grid-template-columns: 1fr; gap: 24px; }
  .login-copy h1 { font-size: 42px; }
  .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .module-layout, .bottom-layout { grid-template-columns: 1fr; }
  .link-grid, .special-module { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .core-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: relative; height: auto; max-height: 48vh; }
  .workspace { padding: 16px; }
  .topbar { display: grid; }
  .login-screen { padding: 18px; overflow: auto; }
  .login-copy h1 { font-size: 32px; }
  .login-copy p:not(.eyebrow) { font-size: 15px; }
  .login-proof { grid-template-columns: 1fr; }
  .selectors, .context-strip, .dashboard-grid, .link-grid, .special-module { grid-template-columns: 1fr; }
  .core-head, .core-form { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  h1 { font-size: 23px; }
}
