:root {
  color-scheme: light;
  --bg: #f3f6f6;
  --surface: #ffffff;
  --panel: #ffffff;
  --panel-2: #102b36;
  --line: rgba(13, 43, 54, 0.13);
  --ink: #10262e;
  --muted: #697c82;
  --teal: #087f76;
  --amber: #9b6a0e;
  --red: #b43b51;
  --green: #137a55;
  --shadow: 0 24px 70px rgba(20, 46, 55, 0.13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.brand { align-items: center; display: flex; font-size: 0.82rem; font-weight: 850; gap: 0.7rem; letter-spacing: 0.08em; }
.brand-mark { align-items: center; background: #102b36; border-radius: 0.48rem; color: #ffffff; display: inline-flex; height: 34px; justify-content: center; letter-spacing: -0.03em; width: 34px; }
.environment { background: #fff9ea; border: 1px solid rgba(155, 106, 14, 0.28); border-radius: 99px; color: var(--amber); display: inline-flex; font-size: 0.58rem; font-weight: 900; letter-spacing: 0.14em; padding: 0.42rem 0.62rem; width: fit-content; }
.eyebrow { color: var(--teal); font-size: 0.64rem; font-weight: 850; letter-spacing: 0.15em; margin: 0 0 0.6rem; }

.auth-gate { align-items: center; background: radial-gradient(circle at 80% 10%, rgba(8, 127, 118, 0.11), transparent 32rem), linear-gradient(145deg, #f8fbfb, #edf3f3); display: flex; justify-content: center; min-height: 100vh; padding: 2rem; }
.auth-card { background: #ffffff; border: 1px solid var(--line); border-radius: 1.2rem; box-shadow: var(--shadow); display: grid; gap: 1.35rem; grid-template-columns: minmax(0, 1fr) auto; max-width: 460px; padding: 1.75rem; width: 100%; }
.auth-card > .brand { grid-column: 1; }
.auth-card .environment { align-self: center; grid-column: 2; justify-self: end; position: static; transform: none; }
.auth-copy { border-top: 1px solid var(--line); grid-column: 1 / -1; padding-top: 2.15rem; text-align: center; }
.auth-copy .eyebrow { text-align: center; }
.auth-copy h1 { font-size: clamp(1.7rem, 5vw, 2.25rem); letter-spacing: 0.12em; line-height: 1.08; margin: 0 0 1rem; text-align: center; white-space: nowrap; }
.auth-copy p:last-child { color: var(--muted); line-height: 1.6; margin: 0 auto; max-width: 370px; }
.auth-card > .google-button, .auth-card > .auth-message { grid-column: 1 / -1; }
.auth-message { color: var(--muted); font-size: 0.75rem; line-height: 1.5; margin: 0; text-align: center; }
.auth-message.error { color: var(--red); }
.google-button { align-items: center; gap: 0.65rem; width: 100%; }
.google-mark { align-items: center; background: #fff; border-radius: 50%; color: #2467d1; display: inline-flex; height: 23px; justify-content: center; width: 23px; }

.button { background: transparent; border: 1px solid var(--line); border-radius: 0.55rem; cursor: pointer; display: inline-flex; font-size: 0.78rem; font-weight: 750; justify-content: center; padding: 0.72rem 0.9rem; }
.button:hover, .button:focus-visible { background: rgba(16,43,54,0.055); }
.button.primary { background: #102b36; border-color: #102b36; color: #ffffff; }
.button.primary:hover, .button.primary:focus-visible { background: #1a4351; }
.button.small { padding: 0.58rem 0.72rem; }
.button:disabled { cursor: wait; opacity: 0.55; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #ffffff; border-right: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; padding: 1.5rem 1.2rem; position: sticky; top: 0; }
.sidebar .environment { margin-top: 1.2rem; }
.sidebar nav { display: grid; gap: 0.35rem; margin-top: 3rem; }
.sidebar nav a { align-items: center; border-radius: 0.55rem; color: var(--muted); display: flex; font-size: 0.78rem; justify-content: space-between; padding: 0.72rem 0.8rem; text-decoration: none; }
.sidebar nav a:hover, .sidebar nav a.active { background: #edf5f4; color: var(--ink); }
.nav-count { align-items: center; background: #fff5d9; border-radius: 99px; color: var(--amber); display: inline-flex; font-size: 0.58rem; height: 20px; justify-content: center; min-width: 20px; padding: 0 0.35rem; }
.sidebar-footer { align-items: center; border-top: 1px solid var(--line); color: var(--muted); display: grid; font-size: 0.66rem; gap: 0.2rem 0.55rem; grid-template-columns: auto 1fr; margin-top: auto; padding: 1rem 0.75rem 0; }
.sidebar-footer span:first-child { grid-column: 1 / -1; }
.sidebar-footer strong { color: var(--amber); font-size: 0.68rem; }

main { min-width: 0; padding: 0 4vw 6rem; }
.console-header { align-items: center; backdrop-filter: blur(12px); background: rgba(243,246,246,0.92); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; min-height: 98px; position: sticky; top: 0; z-index: 5; }
.console-header h2 { font-size: 1.65rem; letter-spacing: -0.035em; margin: 0; }
.account { align-items: center; display: flex; gap: 1rem; }
.account div { display: grid; gap: 0.2rem; text-align: right; }
.account strong { font-size: 0.76rem; }
.account span { color: var(--teal); font-size: 0.56rem; font-weight: 850; letter-spacing: 0.1em; }
.icon-button { background: transparent; border: 1px solid var(--line); border-radius: 0.5rem; cursor: pointer; font-size: 0.7rem; padding: 0.55rem 0.65rem; }

.console-section { border-top: 1px solid var(--line); padding: 3.5rem 0 1rem; scroll-margin-top: 95px; }
.console-section:first-of-type { border-top: 0; }
.section-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 1.5rem; }
.section-heading h3 { font-size: 1.7rem; letter-spacing: -0.04em; margin: 0; }
.metric-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(4, 1fr); }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem; box-shadow: 0 8px 24px rgba(20,46,55,0.035); display: grid; min-height: 145px; padding: 1rem; }
.metric:first-child { background: #102b36; border-color: #102b36; color: #ffffff; }
.metric:first-child > span, .metric:first-child small { color: #adc1c7; }
.metric > span { color: var(--muted); font-size: 0.72rem; }
.metric strong { align-self: end; font-size: 2.6rem; letter-spacing: -0.06em; }
.metric small { color: var(--muted); font-size: 0.62rem; }
.system-strip { background: #ffffff; border: 1px solid var(--line); border-radius: 0.8rem; display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 0.8rem; padding: 1rem; }
.system-strip div { align-items: center; border-right: 1px solid var(--line); display: grid; gap: 0.16rem 0.55rem; grid-template-columns: auto 1fr; padding: 0 1rem; }
.system-strip div:last-child { border: 0; }
.system-strip strong { font-size: 0.72rem; }
.system-strip small { color: var(--muted); font-size: 0.62rem; grid-column: 2; }
.status-dot { background: var(--muted); border-radius: 50%; display: inline-block; height: 8px; width: 8px; }
.status-dot.green { background: var(--green); box-shadow: 0 0 0 5px rgba(19,122,85,0.08); }
.status-dot.amber { background: var(--amber); }
.status-dot.neutral { background: var(--muted); }

.table-wrap { background: #ffffff; border: 1px solid var(--line); border-radius: 0.8rem; overflow-x: auto; }
table { border-collapse: collapse; min-width: 850px; width: 100%; }
th { background: #f7f9f9; color: var(--muted); font-size: 0.61rem; font-weight: 750; letter-spacing: 0.07em; padding: 0.78rem 0.9rem; text-align: left; text-transform: uppercase; }
td { border-top: 1px solid var(--line); color: #4a6169; font-size: 0.72rem; padding: 0.85rem 0.9rem; }
td strong { color: var(--ink); display: block; font-size: 0.75rem; }
td small { color: var(--muted); }
td code { color: var(--teal); font-size: 0.68rem; }
td.empty { color: var(--muted); padding: 2.2rem; text-align: center; }
.row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }
.row-button { background: transparent; border: 1px solid var(--line); border-radius: 0.4rem; cursor: pointer; font-size: 0.62rem; padding: 0.42rem 0.55rem; }
.row-button.approve { border-color: rgba(85,214,167,0.35); color: var(--green); }
.row-button.reject { color: var(--muted); }
.badge { border-radius: 99px; display: inline-flex; font-size: 0.56rem; font-weight: 850; letter-spacing: 0.06em; padding: 0.3rem 0.45rem; }
.badge.active, .badge.approved { background: rgba(19,122,85,0.1); color: var(--green); }
.badge.pending { background: rgba(155,106,14,0.11); color: var(--amber); }
.badge.rejected { background: rgba(180,59,81,0.1); color: var(--red); }

.api-hero { background: #ffffff; border: 1px solid rgba(8,127,118,0.22); border-radius: 0.8rem; display: grid; grid-template-columns: 2fr 1.6fr 0.7fr 0.7fr; margin-bottom: 0.8rem; padding: 1rem; }
.api-hero div { border-right: 1px solid var(--line); display: grid; gap: 0.45rem; min-width: 0; padding: 0 1rem; }
.api-hero div:first-child { padding-left: 0; }
.api-hero div:last-child { border-right: 0; padding-right: 0; }
.api-hero span { color: var(--muted); font-size: 0.65rem; }
.api-hero code { color: var(--teal); font-size: 0.7rem; overflow-wrap: anywhere; }
.api-hero strong { font-size: 0.75rem; }
.api-flow { align-items: stretch; border: 1px solid var(--line); border-radius: 0.8rem; display: grid; gap: 0.55rem; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; margin-bottom: 0.8rem; padding: 1rem; }
.api-flow { background: #ffffff; }
.api-flow div { background: #f7f9f9; border-radius: 0.55rem; display: grid; gap: 0.35rem; padding: 0.75rem; }
.api-flow b { align-items: center; background: rgba(8,127,118,0.11); border-radius: 50%; color: var(--teal); display: inline-flex; font-size: 0.62rem; height: 22px; justify-content: center; width: 22px; }
.api-flow span { font-size: 0.7rem; font-weight: 750; }
.api-flow code { color: var(--muted); font-size: 0.6rem; overflow-wrap: anywhere; }
.api-flow i { align-self: center; color: var(--teal); font-style: normal; }
.api-endpoints { margin-bottom: 0.8rem; }
.method { border-radius: 0.35rem; display: inline-flex; font-size: 0.57rem; font-weight: 900; justify-content: center; min-width: 42px; padding: 0.3rem 0.4rem; }
.method.get { background: rgba(8,127,118,0.1); color: var(--teal); }
.method.post { background: rgba(155,106,14,0.11); color: var(--amber); }
.code-grid { display: grid; gap: 0.8rem; grid-template-columns: 1.2fr 0.8fr; }
.code-grid article { background: #ffffff; border: 1px solid var(--line); border-radius: 0.8rem; min-width: 0; overflow: hidden; }
.code-grid article > div { align-items: center; background: #f7f9f9; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 0.8rem 0.9rem; }
.code-grid article > div span { color: var(--muted); font-size: 0.65rem; }
.code-grid article > div code { color: var(--teal); font-size: 0.64rem; }
.code-grid pre { color: #183841; font-size: 0.68rem; line-height: 1.55; margin: 0; max-height: 500px; overflow: auto; padding: 1rem; white-space: pre-wrap; }
.api-note { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.7rem; line-height: 1.55; margin: 0; padding: 1rem; }
.api-note strong { color: var(--ink); }
.api-note code { color: var(--teal); }

.preview-label { background: #eef5f4; border: 1px solid rgba(8,127,118,0.18); border-radius: 99px; color: var(--teal); font-size: 0.58rem; font-weight: 850; letter-spacing: 0.08em; padding: 0.45rem 0.65rem; }
.invoice-preview-layout { align-items: start; display: grid; gap: 1rem; grid-template-columns: 235px minmax(0, 1fr); }
.preview-options { background: #ffffff; border: 1px solid var(--line); border-radius: 0.8rem; display: grid; gap: 0; overflow: hidden; }
.preview-options > div { border-bottom: 1px solid var(--line); display: grid; gap: 0.35rem; padding: 0.85rem; }
.preview-options span { color: var(--muted); font-size: 0.62rem; }
.preview-options strong { font-size: 0.76rem; }
.preview-options ul { color: #4a6169; display: grid; font-size: 0.68rem; gap: 0.35rem; margin: 0.2rem 0 0; padding-left: 1rem; }
.preview-options p { color: var(--muted); font-size: 0.66rem; line-height: 1.55; margin: 0; padding: 0.85rem; }
.preview-options .button { margin: 0 0.85rem 0.85rem; }
.invoice-canvas { background: #e8eded; border: 1px solid var(--line); border-radius: 0.8rem; overflow: auto; padding: clamp(1rem, 3vw, 2.2rem); }
.invoice-sheet { background: #ffffff; box-shadow: 0 16px 50px rgba(20,46,55,0.13); color: #152d35; margin: 0 auto; min-height: 900px; min-width: 650px; padding: 2.5rem; width: min(100%, 760px); }
.invoice-document-header { align-items: start; border-bottom: 3px solid #102b36; display: flex; justify-content: space-between; padding-bottom: 1.5rem; }
.invoice-logo { align-items: center; display: flex; gap: 0.7rem; }
.invoice-logo > span { align-items: center; background: #102b36; border-radius: 0.45rem; color: #ffffff; display: inline-flex; font-size: 0.8rem; font-weight: 850; height: 42px; justify-content: center; width: 42px; }
.invoice-logo div { display: grid; gap: 0.15rem; }
.invoice-logo strong { font-size: 0.78rem; letter-spacing: 0.06em; }
.invoice-logo small { color: #73868b; font-size: 0.55rem; }
.invoice-title { display: grid; justify-items: end; }
.invoice-title h4 { font-size: 1.65rem; letter-spacing: 0.03em; margin: 0.35rem 0 0.15rem; }
.invoice-title > strong { font-size: 0.78rem; }
.document-status { background: #fff5d9; border-radius: 99px; color: #8e6008; font-size: 0.52rem; font-weight: 850; letter-spacing: 0.08em; padding: 0.3rem 0.45rem; }
.invoice-dates { border-bottom: 1px solid #dde5e6; display: grid; grid-template-columns: repeat(3, 1fr); padding: 1rem 0; }
.invoice-dates div { border-right: 1px solid #dde5e6; display: grid; gap: 0.2rem; padding: 0 0.8rem; }
.invoice-dates div:first-child { padding-left: 0; }
.invoice-dates div:last-child { border-right: 0; }
.invoice-dates span, .invoice-parties > section > span, .payment-details > span, .invoice-document-footer span { color: #708389; font-size: 0.52rem; font-weight: 800; letter-spacing: 0.08em; }
.invoice-dates strong { font-size: 0.7rem; }
.invoice-parties { display: grid; gap: 2rem; grid-template-columns: 1fr 1fr; padding: 1.6rem 0; }
.invoice-parties section { border-left: 3px solid #dbe7e6; padding-left: 0.8rem; }
.invoice-parties h5 { font-size: 0.78rem; margin: 0.45rem 0 0.35rem; }
.invoice-parties p { color: #536970; font-size: 0.62rem; line-height: 1.55; margin: 0; }
.invoice-lines { border: 1px solid #dbe3e4; border-radius: 0.5rem; overflow: hidden; }
.invoice-lines table { min-width: 0; }
.invoice-lines th { background: #102b36; color: #dfeaec; font-size: 0.5rem; letter-spacing: 0.05em; padding: 0.65rem 0.55rem; }
.invoice-lines td { border-color: #e2e8e9; color: #445b62; font-size: 0.58rem; padding: 0.72rem 0.55rem; white-space: nowrap; }
.invoice-lines td:nth-child(2) { white-space: normal; width: 35%; }
.invoice-lines td strong { color: #152d35; font-size: 0.62rem; }
.invoice-lines td small { color: #7b8d92; display: block; margin-top: 0.15rem; }
.invoice-summary { display: grid; gap: 2rem; grid-template-columns: 1fr 0.85fr; padding: 1.4rem 0; }
.payment-details { display: grid; align-content: start; gap: 0.35rem; }
.payment-details strong { font-size: 0.7rem; margin-top: 0.2rem; }
.payment-details p { color: #5e7278; font-size: 0.58rem; line-height: 1.5; margin: 0; }
.totals { display: grid; gap: 0.5rem; }
.totals p { align-items: center; display: flex; font-size: 0.62rem; justify-content: space-between; margin: 0; }
.totals span { color: #667b81; }
.totals .grand-total { border-top: 2px solid #102b36; font-size: 0.72rem; margin-top: 0.25rem; padding-top: 0.75rem; }
.totals .grand-total span, .totals .grand-total strong { color: #102b36; }
.invoice-document-footer { align-items: center; background: #f2f6f5; border-radius: 0.55rem; display: flex; justify-content: space-between; padding: 0.8rem; }
.invoice-document-footer > div:first-child { display: grid; gap: 0.2rem; }
.invoice-document-footer strong { font-size: 0.64rem; }
.invoice-document-footer small { color: #71858a; font-size: 0.54rem; }
.qr-placeholder { align-items: center; background: repeating-conic-gradient(#102b36 0 25%, #ffffff 0 50%) 50% / 10px 10px; border: 4px solid #ffffff; box-shadow: 0 0 0 1px #cad5d7; display: flex; height: 54px; justify-content: center; width: 54px; }
.qr-placeholder span { background: #ffffff; color: #102b36; font-size: 0.5rem; padding: 0.15rem; }
.invoice-disclaimer { color: #8a999d; font-size: 0.5rem; margin: 0.65rem 0 0; text-align: center; }

.request-form { background: var(--panel); border: 1px solid rgba(94,215,202,0.25); border-radius: 0.8rem; display: grid; gap: 1rem; grid-template-columns: repeat(3, 1fr); margin-bottom: 1rem; padding: 1rem; }
.request-form label { color: var(--muted); display: grid; font-size: 0.65rem; gap: 0.4rem; }
.request-form input, .request-form select, .request-form textarea { background: #f7f9f9; border: 1px solid var(--line); border-radius: 0.45rem; color: var(--ink); font-size: 0.72rem; outline: none; padding: 0.65rem; resize: vertical; }
.request-form input:focus, .request-form select:focus, .request-form textarea:focus { border-color: var(--teal); }
.request-form fieldset { border: 1px solid var(--line); border-radius: 0.45rem; display: flex; gap: 1rem; margin: 0; padding: 0.65rem; }
.request-form legend { color: var(--muted); font-size: 0.65rem; }
.request-form fieldset label { align-items: center; display: flex; }
.form-wide { grid-column: span 2; }
.form-actions { align-items: end; display: flex; gap: 0.5rem; justify-content: flex-end; }

.settings-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(3, 1fr); }
.settings-grid article { background: var(--panel); border: 1px solid var(--line); border-radius: 0.75rem; display: grid; gap: 1rem; min-height: 115px; padding: 1rem; }
.settings-grid span { color: var(--muted); font-size: 0.68rem; }
.settings-grid strong { align-self: end; font-size: 0.82rem; overflow-wrap: anywhere; }

dialog { background: transparent; border: 0; color: var(--ink); max-width: 590px; width: calc(100% - 2rem); }
dialog::backdrop { backdrop-filter: blur(8px); background: rgba(2,12,17,0.72); }
.dialog-content { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); padding: 1.4rem; }
.dialog-content h3 { font-size: 1.5rem; margin: 0 0 0.7rem; }
.dialog-content p:not(.eyebrow) { color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.dialog-content code { background: #f6f8f8; border: 1px solid var(--line); border-radius: 0.55rem; display: block; font-size: 0.7rem; margin: 1rem 0; overflow-wrap: anywhere; padding: 1rem; }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.toast { background: var(--panel-2); border: 1px solid var(--panel-2); border-radius: 0.55rem; bottom: 1rem; box-shadow: var(--shadow); color: #ffffff; font-size: 0.72rem; padding: 0.75rem 0.9rem; position: fixed; right: 1rem; z-index: 20; }

@media (max-width: 1050px) {
  .metric-grid, .system-strip { grid-template-columns: repeat(2, 1fr); }
  .system-strip div:nth-child(2) { border-right: 0; }
  .system-strip div:nth-child(n+3) { border-top: 1px solid var(--line); padding-top: 1rem; }
  .request-form, .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .api-hero { grid-template-columns: repeat(2, 1fr); }
  .api-hero div { border-bottom: 1px solid var(--line); padding: 0.8rem; }
  .api-hero div:nth-child(2) { border-right: 0; }
  .api-hero div:nth-child(n+3) { border-bottom: 0; }
  .api-flow { grid-template-columns: 1fr 1fr; }
  .api-flow i { display: none; }
  .invoice-preview-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .sidebar nav { display: flex; margin-top: 1.5rem; overflow-x: auto; }
  .sidebar nav a { flex: 0 0 auto; }
  .sidebar-footer { display: none; }
  main { padding: 0 1rem 4rem; }
  .console-header { min-height: 85px; }
  .console-header h2 { font-size: 1.25rem; }
  .account div { display: none; }
  .metric-grid, .system-strip, .request-form, .settings-grid, .api-hero, .api-flow, .code-grid { grid-template-columns: 1fr; }
  .api-hero div { border-bottom: 1px solid var(--line); border-right: 0; padding: 0.8rem 0; }
  .api-hero div:nth-child(2) { border-bottom: 1px solid var(--line); }
  .system-strip div { border-bottom: 1px solid var(--line); border-right: 0; padding: 0.8rem 0; }
  .system-strip div:nth-child(n+3) { border-top: 0; }
  .form-wide { grid-column: auto; }
  .invoice-canvas { padding: 0.75rem; }
  .auth-card { gap: 1.15rem; padding: 1.35rem; }
  .auth-copy { padding-top: 1.65rem; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
