:root {
  --ink: #101511;
  --ink-soft: #4f5b51;
  --paper: #f5f4ed;
  --card: #fffef8;
  --line: #d8d9cf;
  --lime: #c9ff57;
  --mint: #55d68b;
  --red: #b53a34;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 99; background: var(--lime); color: var(--ink); padding: .75rem 1rem; font-weight: 800; }
.skip-link:focus { top: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; font-size: 1.2rem; font-weight: 800; letter-spacing: -.04em; }
.brand--light { color: white; }
.brand-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; background: var(--lime); color: var(--ink); border-radius: .4rem; font-weight: 900; }
.eyebrow { margin: 0 0 .65rem; font: 700 .7rem/1 var(--mono); letter-spacing: .13em; color: var(--ink-soft); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(350px, .9fr) minmax(480px, 1.1fr); }
.login-brand-panel { min-height: 100vh; padding: clamp(2rem, 5vw, 5rem); color: white; background: var(--ink); display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-brand-panel::after { content: "L."; position: absolute; right: -3rem; bottom: -8rem; font-size: 25rem; font-weight: 900; line-height: 1; color: rgba(255,255,255,.025); }
.login-copy { position: relative; z-index: 1; max-width: 36rem; }
.login-copy .eyebrow { color: var(--lime); }
.login-copy h1 { margin: 0; font-size: clamp(3.2rem, 6vw, 6.5rem); line-height: .88; letter-spacing: -.075em; }
.login-copy h1 em { color: var(--lime); font-style: normal; }
.login-copy > p:last-child { max-width: 32rem; color: #aeb8b0; font-size: 1.05rem; line-height: 1.65; }
.signal, .api-status { display: flex; align-items: center; gap: .55rem; font: 700 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.signal i, .api-status i { width: .55rem; height: .55rem; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 .3rem rgba(85,214,139,.13); }
.login-access-panel { display: grid; place-items: center; padding: 2rem; background-image: linear-gradient(rgba(16,21,17,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(16,21,17,.045) 1px, transparent 1px); background-size: 32px 32px; }
.login-card { width: min(100%, 31rem); padding: clamp(2rem, 5vw, 3.2rem); border: 1px solid var(--line); background: rgba(255,254,248,.94); box-shadow: 0 1.5rem 5rem rgba(16,21,17,.08); }
.login-card h2 { margin: 0; font-size: 2rem; letter-spacing: -.045em; }
.login-card > div:first-child > p:last-child { color: var(--ink-soft); line-height: 1.5; margin-bottom: 2rem; }
label { display: block; margin: 1rem 0 .5rem; font-size: .8rem; font-weight: 800; }
input, select { width: 100%; border: 1px solid #bfc4ba; background: white; color: var(--ink); padding: .95rem 1rem; outline: none; border-radius: .2rem; }
input:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(201,255,87,.55); }
.secret-field { position: relative; }
.secret-field input { padding-right: 5.5rem; font-family: var(--mono); }
.secret-field button { position: absolute; right: .45rem; top: .42rem; bottom: .42rem; border: 0; background: #eef0e7; padding: 0 .7rem; font-size: .72rem; font-weight: 800; cursor: pointer; }
.field-help { margin: .55rem 0 0; color: var(--ink-soft); font-size: .76rem; }
.form-error { min-height: 1.3rem; color: var(--red); font-size: .82rem; font-weight: 700; }
.button { display: inline-flex; align-items: center; justify-content: space-between; gap: 1rem; border: 1px solid var(--ink); padding: .9rem 1rem; font-weight: 800; cursor: pointer; text-decoration: none; }
.button:disabled { cursor: wait; opacity: .65; }
.button--primary { width: 100%; background: var(--ink); color: white; }
.button--primary span { color: var(--lime); }
.button--secondary { background: transparent; color: var(--ink); }
.docs-link { display: block; margin-top: 1.2rem; color: var(--ink-soft); text-align: center; font-size: .8rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 15rem 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: white; padding: 1.6rem; display: flex; flex-direction: column; }
.sidebar nav { display: grid; gap: .35rem; margin-top: 4rem; }
.sidebar nav a { display: flex; gap: .8rem; align-items: center; padding: .8rem; color: #9faa9f; text-decoration: none; font-size: .85rem; border-left: 2px solid transparent; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; border-left-color: var(--lime); background: rgba(255,255,255,.04); }
.sidebar nav span { font: 600 .65rem/1 var(--mono); color: var(--lime); }
.logout-button { margin-top: auto; border: 1px solid #3b453d; background: transparent; color: #c6cec8; padding: .8rem; cursor: pointer; text-align: left; }
.app-body { min-width: 0; }
.topbar { height: 5rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(1.2rem, 4vw, 4rem); background: rgba(245,244,237,.92); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(10px); }
.topbar .eyebrow { margin-bottom: .3rem; }
.api-status { color: #277a49; }
main { padding: 0 clamp(1.2rem, 4vw, 4rem) 5rem; }
.page-section { padding-top: clamp(2.5rem, 6vw, 5rem); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.section-heading h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.8rem); letter-spacing: -.065em; line-height: 1; }
.section-heading > p { max-width: 31rem; color: var(--ink-soft); line-height: 1.55; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--card); }
.metric-grid article { padding: 1.5rem; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border: 0; }
.metric-grid span { display: block; color: var(--ink-soft); font: 700 .65rem/1 var(--mono); letter-spacing: .1em; }
.metric-grid strong { display: block; margin: .8rem 0 .25rem; font-size: clamp(1.7rem, 3vw, 2.6rem); letter-spacing: -.05em; text-transform: capitalize; }
.metric-grid small { color: var(--ink-soft); }
.quota-card, .breakdown-card { margin-top: 1.2rem; border: 1px solid var(--line); background: var(--card); padding: 1.6rem; }
.quota-card > div:first-child { display: flex; align-items: flex-end; justify-content: space-between; }
.quota-card h2, .breakdown-card h2 { margin: 0; letter-spacing: -.035em; }
.quota-track { display: block; width: 100%; height: .72rem; margin: 1.5rem 0 .7rem; border: 0; background: #e4e6dc; overflow: hidden; appearance: none; }
.quota-track::-webkit-progress-bar { background: #e4e6dc; }
.quota-track::-webkit-progress-value { background: var(--lime); border-right: 2px solid var(--ink); transition: width .4s ease; }
.quota-track::-moz-progress-bar { background: var(--lime); border-right: 2px solid var(--ink); }
.quota-card > p { margin: 0; color: var(--ink-soft); font-size: .8rem; }
.table-wrap { overflow-x: auto; margin-top: 1.2rem; }
table { width: 100%; border-collapse: collapse; min-width: 34rem; }
th, td { padding: .85rem .5rem; border-top: 1px solid var(--line); text-align: right; font-size: .82rem; }
th:first-child, td:first-child { text-align: left; text-transform: capitalize; }
th { color: var(--ink-soft); font: 700 .65rem/1 var(--mono); letter-spacing: .06em; }
.reader-section { border-top: 1px solid var(--line); margin-top: 5rem; }
.reader-grid { display: grid; grid-template-columns: minmax(16rem, .65fr) minmax(0, 1.35fr); gap: 1.2rem; }
.reader-form { border: 1px solid var(--line); background: var(--card); padding: 1.6rem; align-self: start; }
.reader-form .button { margin-top: 1.5rem; }
.output-card { min-width: 0; border: 1px solid #303a32; background: var(--ink); color: #dce3dd; }
.output-card header, .output-card footer { display: flex; justify-content: space-between; padding: .9rem 1rem; color: #8f9a91; font: 700 .67rem/1 var(--mono); letter-spacing: .06em; }
.output-card header { border-bottom: 1px solid #303a32; }
.output-card header b { color: var(--lime); }
.output-card footer { border-top: 1px solid #303a32; overflow-wrap: anywhere; }
.output-card pre { min-height: 22rem; max-height: 38rem; overflow: auto; margin: 0; padding: 1.2rem; white-space: pre-wrap; overflow-wrap: anywhere; font: .78rem/1.7 var(--mono); }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 20rem; padding: 2rem; }
  .login-copy h1 { font-size: 3.3rem; }
  .login-copy > p:last-child { display: none; }
  .login-access-panel { min-height: calc(100vh - 20rem); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 1rem 1.2rem; flex-direction: row; align-items: center; gap: 1rem; overflow-x: auto; }
  .sidebar nav { display: flex; margin: 0 0 0 auto; white-space: nowrap; }
  .sidebar nav a { border-left: 0; border-bottom: 2px solid transparent; }
  .sidebar nav a.active { border-bottom-color: var(--lime); }
  .logout-button { margin: 0; white-space: nowrap; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid article:nth-child(2) { border-right: 0; }
  .metric-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .login-access-panel { padding: 1rem; }
  .login-card { padding: 1.5rem; }
  .sidebar { flex-wrap: wrap; }
  .sidebar nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .sidebar nav a { padding: .65rem; }
  .topbar { height: 4.4rem; }
  .section-heading { display: grid; align-items: start; }
  .section-heading .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-grid article:nth-child(3) { border-bottom: 1px solid var(--line); }
  .reader-grid { grid-template-columns: 1fr; }
  .output-card pre { min-height: 18rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
