:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #68716d;
  --paper: #f5f2ea;
  --panel: #fffdf8;
  --line: #ded9ce;
  --navy: #172a3a;
  --navy-2: #223d51;
  --amber: #d99b37;
  --amber-soft: #f6e8cb;
  --green: #1d7b5a;
  --red: #b7493f;
  --shadow: 0 20px 50px rgba(28, 38, 34, .10);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(217, 155, 55, .35); outline-offset: 2px; }
[hidden] { display: none !important; }

.eyebrow { margin: 0 0 6px; color: var(--amber); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.brand-mark { display: grid; width: 58px; height: 58px; place-items: center; border: 1px solid rgba(255,255,255,.3); border-radius: 18px; background: var(--amber); color: var(--navy); font: 800 27px Georgia, serif; box-shadow: inset 0 0 0 6px rgba(255,255,255,.14); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); background: var(--navy); }
.login-brand { display: flex; flex-direction: column; justify-content: center; padding: clamp(48px, 8vw, 120px); color: #fff; background-image: radial-gradient(circle at 20% 20%, rgba(217,155,55,.18), transparent 28%), linear-gradient(120deg, transparent 65%, rgba(255,255,255,.04)); }
.login-brand h1 { max-width: 720px; margin: 26px 0 20px; font: 500 clamp(46px, 6vw, 86px)/.98 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
.login-copy { max-width: 560px; margin: 0; color: #c7d2d7; font-size: 18px; }
.signal-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 42px; }
.signal-list span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: #dce5e8; font-size: 12px; }
.login-card { align-self: center; width: min(460px, calc(100% - 48px)); margin: auto; padding: 40px; border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); }
.login-card h2 { margin: 0; font: 500 38px/1.1 Georgia, serif; }
.login-card p:not(.eyebrow):not(.form-error) { margin: 8px 0 28px; color: var(--muted); }
.login-card label, .form-grid label { display: grid; gap: 7px; margin-top: 16px; color: #35413d; font-size: 13px; font-weight: 700; }
.login-card input, .form-grid input, .form-grid select, .form-grid textarea, .tenant-picker select, .table-toolbar input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); padding: 11px 12px; }
.form-grid textarea { min-height: 112px; resize: vertical; }
.login-card small { display: block; margin-top: 18px; color: var(--muted); text-align: center; }
.form-error { min-height: 20px; color: var(--red); font-size: 13px; }
.google-login { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 16px; border: 1px solid #d9dce1; border-radius: 10px; background: #fff; color: #263238; font-size: 14px; font-weight: 750; text-decoration: none; box-shadow: 0 5px 14px rgba(28,38,34,.07); }
.google-login:hover { border-color: #b9bec5; background: #fafafa; }
.google-login svg { width: 21px; height: 21px; flex: 0 0 auto; }
.emergency-login { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.emergency-login summary { cursor: pointer; color: var(--muted); font-size: 11px; text-align: center; }
.emergency-login form { padding-top: 4px; }
.emergency-login button { margin-top: 16px; }

.primary, .ghost, .icon-button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 750; }
.primary { background: var(--amber); color: #1d2830; box-shadow: 0 8px 20px rgba(217,155,55,.20); }
.primary:hover { background: #e6aa49; }
.primary:disabled { cursor: not-allowed; opacity: .55; }
.ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
.wide { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 18px; background: var(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand b, .brand small { display: block; }
.brand b { font: 600 18px Georgia, serif; }
.brand small { margin-top: 2px; color: #9fb0ba; font-size: 11px; }
nav { display: grid; gap: 5px; margin-top: 24px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; color: #b9c8cf; text-align: left; }
.nav-item span { color: #718996; font: 700 10px/1 ui-monospace, monospace; }
.nav-item:hover, .nav-item.active { background: var(--navy-2); color: #fff; }
.nav-item.active span { color: var(--amber); }
.sidebar-foot { margin-top: auto; }
.sidebar .ghost { border-color: rgba(255,255,255,.14); color: #d8e1e4; }
.health-dot { display: flex; align-items: center; gap: 8px; margin: 0 8px 14px; color: #aebcc3; font-size: 12px; }
.health-dot i { width: 8px; height: 8px; border-radius: 50%; background: #4dcc91; box-shadow: 0 0 0 4px rgba(77,204,145,.12); }

main { min-width: 0; }
.topbar { min-height: 102px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px clamp(22px, 4vw, 56px); border-bottom: 1px solid var(--line); background: rgba(245,242,234,.94); }
.topbar h1 { margin: 0; font: 500 31px/1.05 Georgia, serif; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: end; gap: 12px; }
.tenant-picker { display: grid; gap: 4px; min-width: 220px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.menu-toggle { display: none; }
.content { max-width: 1500px; margin: 0 auto; padding: 34px clamp(22px, 4vw, 56px) 70px; }

.hero { display: grid; grid-template-columns: 1.4fr .6fr; gap: 22px; padding: clamp(26px, 4vw, 44px); border-radius: 20px; background: var(--navy); color: #fff; overflow: hidden; }
.hero h2 { max-width: 720px; margin: 8px 0 14px; font: 500 clamp(34px, 4vw, 58px)/1.02 Georgia, serif; letter-spacing: -.035em; }
.hero p { max-width: 670px; margin: 0; color: #bfccd2; }
.hero-signal { align-self: stretch; display: grid; place-content: center; border-left: 1px solid rgba(255,255,255,.12); text-align: center; }
.hero-signal b { font: 500 54px/1 Georgia, serif; color: var(--amber); }
.hero-signal span { margin-top: 7px; color: #b9c8cf; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.metric { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.metric span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.metric b { display: block; margin-top: 7px; font: 500 35px/1 Georgia, serif; }
.metric em { display: block; margin-top: 9px; color: var(--green); font-size: 12px; font-style: normal; }
.panel-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; margin-top: 18px; }
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 8px 22px rgba(28,38,34,.035); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font: 600 18px Georgia, serif; }
.panel-body { padding: 18px 20px; }
.stage-row { display: grid; grid-template-columns: 130px 1fr 32px; align-items: center; gap: 10px; margin: 12px 0; }
.stage-row span { color: var(--muted); font-size: 12px; }
.bar { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 999px; background: #ebe6da; appearance: none; }
.bar::-webkit-progress-bar { border-radius: inherit; background: #ebe6da; }
.bar::-webkit-progress-value { border-radius: inherit; background: var(--amber); }
.bar::-moz-progress-bar { border-radius: inherit; background: var(--amber); }
.task-line { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid #ece8de; }
.task-line:last-child { border-bottom: 0; }
.task-line i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.task-line small { color: var(--muted); }

.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.table-toolbar input { max-width: 360px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid #ebe7dd; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #faf8f2; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px 9px; color: var(--ink); font-size: 12px; }
.row-actions .danger { color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; background: var(--amber-soft); color: #79531c; font-size: 11px; font-weight: 800; }
.badge.connected, .badge.active { background: #dcefe7; color: #176445; }
.badge.error, .badge.overdue { background: #f6dfdc; color: #913b33; }
.empty { padding: 54px 24px; color: var(--muted); text-align: center; }

.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.integration-card { min-height: 270px; display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.integration-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.integration-logo { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; background: var(--navy); color: #fff; font: 700 18px Georgia, serif; }
.integration-card h3 { margin: 18px 0 7px; font: 600 24px Georgia, serif; }
.integration-card p { margin: 0; color: var(--muted); }
.integration-meta { display: grid; gap: 7px; margin: 20px 0; padding: 13px; border-radius: 10px; background: #f7f3e9; color: var(--muted); font-size: 12px; }
.integration-card footer { display: flex; gap: 9px; margin-top: auto; }

.approval-hero { display: grid; grid-template-columns: 1fr 180px; gap: 24px; align-items: center; padding: 30px; border-radius: 18px; background: var(--navy); color: #fff; }
.approval-hero h2 { margin: 4px 0 10px; font: 500 35px/1.08 Georgia, serif; }
.approval-hero p:last-child { max-width: 820px; margin: 0; color: #bfccd2; }
.approval-count { display: grid; place-content: center; min-height: 130px; border-left: 1px solid rgba(255,255,255,.14); text-align: center; }
.approval-count b { color: var(--amber); font: 500 56px/1 Georgia, serif; }
.approval-count span { color: #b9c8cf; }
.approval-list { display: grid; gap: 14px; margin-top: 18px; }
.approval-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.approval-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.approval-card h3 { margin: 4px 0 0; font: 600 20px Georgia, serif; }
.approval-kind { color: var(--amber); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.approval-payload { padding: 18px 20px; }
.approval-payload dl { display: grid; grid-template-columns: 130px 1fr; gap: 9px 16px; margin: 0; }
.approval-payload dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.approval-payload dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.approval-payload pre { max-height: 220px; margin: 0; overflow: auto; white-space: pre-wrap; font: 13px/1.55 ui-monospace, monospace; }
.approval-payload code, .approval-meta code { overflow-wrap: anywhere; font: 11px ui-monospace, monospace; }
.approval-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 13px 20px; border-top: 1px solid var(--line); background: #faf8f2; color: var(--muted); font-size: 11px; }
.approval-card > footer { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); }
.danger-text { color: var(--red); }

.team-summary { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: stretch; margin-bottom: 18px; padding: 26px; border-radius: 18px; background: var(--navy); color: #fff; }
.team-summary > article { display: grid; place-content: center; border-right: 1px solid rgba(255,255,255,.14); }
.team-summary > article span { color: #afbec5; font-size: 12px; text-transform: uppercase; }
.team-summary > article b { margin-top: 8px; color: var(--amber); font: 500 54px/1 Georgia, serif; }
.team-summary h2 { margin: 4px 0 8px; font: 500 31px/1.1 Georgia, serif; }
.team-summary p:last-child { margin: 0; color: #bfccd2; }
.member-name { display: flex; align-items: center; gap: 10px; }
.member-name > span { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 10px; background: var(--amber-soft); color: #79531c; font-weight: 800; }
.member-name b, .member-name small { display: block; }
.member-name small, .muted { color: var(--muted); font-size: 11px; }
.tenant-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 360px; }
.tenant-chips span { padding: 4px 8px; border-radius: 999px; background: #eef1ef; color: #45504c; font-size: 11px; }
.permission-chips { display: flex; flex-wrap: wrap; gap: 5px; min-width: 220px; max-width: 430px; }
.permission-chips span { padding: 4px 7px; border-radius: 7px; background: var(--amber-soft); color: #684819; font-size: 10px; }
.tenant-fieldset { margin-top: 18px; padding: 0; border: 0; }
.tenant-fieldset legend { margin-bottom: 8px; color: #35413d; font-size: 13px; font-weight: 700; }
.tenant-choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tenant-choice { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; margin: 0 !important; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tenant-choice input { width: 18px !important; margin: 0; padding: 0 !important; }
.tenant-choice b, .tenant-choice small { display: block; }
.tenant-choice small { color: var(--muted); font-weight: 500; }
.permission-fieldset { margin-top: 18px; padding: 0; border: 0; }
.permission-fieldset legend { color: #35413d; font-size: 13px; font-weight: 700; }
.permission-fieldset > p { margin: 6px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.permission-choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.permission-choice { display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 10px !important; margin: 0 !important; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.permission-choice input { width: 18px !important; margin: 2px 0 0; padding: 0 !important; }
.permission-choice b, .permission-choice small { display: block; }
.permission-choice small { margin-top: 2px; color: var(--muted); font-weight: 500; line-height: 1.35; }

dialog { width: min(680px, calc(100vw - 28px)); max-height: 90vh; padding: 0; border: 0; border-radius: 18px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(12, 24, 31, .65); backdrop-filter: blur(3px); }
dialog form > header, dialog form > footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 24px; }
dialog form > header { border-bottom: 1px solid var(--line); }
dialog form > footer { border-top: 1px solid var(--line); justify-content: flex-end; }
dialog h2 { margin: 0; font: 600 24px Georgia, serif; }
.icon-button { padding: 3px 11px; background: transparent; color: var(--muted); font-size: 25px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; max-height: 58vh; overflow-y: auto; padding: 4px 24px 24px; }
.form-grid .full { grid-column: 1 / -1; }
.nested-form { max-height: none; padding: 0; overflow: visible; }
.approval-dialog-note { margin: 0; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--amber-soft); color: #684819; font-size: 12px; }
.check-line { display: flex !important; grid-template-columns: 18px 1fr; align-items: center; }
.check-line input { width: 18px; }
dialog .form-error { padding: 0 24px; }
.credential-dialog > section > header, .credential-dialog > section > footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 24px; }
.credential-dialog > section > header { border-bottom: 1px solid var(--line); }
.credential-dialog > section > footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.credential-body { display: grid; gap: 16px; padding: 24px; }
.credential-body p { margin: 0; color: var(--muted); }
.credential-body label { display: grid; gap: 7px; color: #35413d; font-size: 12px; font-weight: 800; }
.credential-body code { overflow-wrap: anywhere; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #f7f3e9; color: var(--ink); font: 700 14px/1.5 ui-monospace, monospace; user-select: all; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 390px; padding: 13px 16px; border-radius: 11px; background: var(--navy); color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.skeleton { min-height: 180px; border-radius: 15px; background: linear-gradient(90deg, #ebe7dd 25%, #f7f4ec 50%, #ebe7dd 75%); background-size: 200% 100%; animation: load 1.4s infinite; }
@keyframes load { to { background-position: -200% 0; } }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; width: 250px; transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); padding: 8px 11px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid, .hero { grid-template-columns: 1fr; }
  .team-summary { grid-template-columns: 1fr; }
  .approval-hero { grid-template-columns: 1fr; }
  .approval-count { min-height: 100px; border-top: 1px solid rgba(255,255,255,.14); border-left: 0; }
  .team-summary > article { min-height: 120px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.14); }
  .hero-signal { min-height: 120px; border-top: 1px solid rgba(255,255,255,.12); border-left: 0; }
}

@media (max-width: 700px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { min-height: 42vh; padding: 34px 24px; }
  .login-brand h1 { margin: 18px 0 12px; font-size: 43px; }
  .signal-list { margin-top: 24px; }
  .login-card { margin: -24px auto 28px; padding: 28px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 18px; }
  .topbar-actions { width: 100%; }
  .tenant-picker { flex: 1; min-width: 0; }
  .content { padding: 22px 18px 50px; }
  .metric-grid, .integration-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tenant-choice-grid, .permission-choice-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .approval-payload dl { grid-template-columns: 1fr; }
}
