:root {
  color-scheme: light;
  --forest: #17382e;
  --forest-deep: #10271f;
  --forest-soft: #285345;
  --sage: #dce6da;
  --sage-deep: #9db2a0;
  --paper: #f5f2e9;
  --card: #fffefa;
  --ink: #1c2c26;
  --muted: #64726b;
  --line: #d9dfd6;
  --accent: #c68a53;
  --danger: #994e43;
  --shadow: 0 18px 48px rgb(31 51 42 / 8%);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { min-width: 320px; min-height: 100vh; margin: 0; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }

h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { color: var(--forest-deep); font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.025em; }
h1 { margin-bottom: .75rem; font-size: clamp(2rem, 3.5vw, 3.15rem); line-height: 1.08; }
h2 { margin-bottom: .55rem; font-size: clamp(1.8rem, 3vw, 2.55rem); line-height: 1.12; }
h3 { margin-bottom: .45rem; font-size: 1.35rem; line-height: 1.2; }
h4 { margin-bottom: .7rem; font-size: 1.12rem; }

.eyebrow {
  margin: 0 0 .55rem;
  color: #718079;
  font-size: .69rem;
  font-weight: 750;
  letter-spacing: .14em;
  line-height: 1.35;
  text-transform: uppercase;
}
.lede { max-width: 68ch; margin: 0; color: var(--muted); font-size: .98rem; }
.muted, .helper { color: var(--muted); }
.helper { margin: -.1rem 0 .35rem; font-size: .82rem; }

button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid #c68a53;
  outline-offset: 3px;
}
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }

.auth-gate {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, .95fr) minmax(320px, 1.05fr);
  overflow: hidden;
  background: var(--paper);
}
.auth-card {
  width: min(100%, 550px);
  align-self: center;
  justify-self: center;
  padding: clamp(1.5rem, 5vw, 4.5rem);
}
.auth-brand { margin-bottom: clamp(2rem, 5vh, 4rem); }
.auth-copy { max-width: 36rem; margin: 0 0 1.7rem; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin: 1.5rem 0 1.25rem; padding: .3rem; border: 1px solid var(--line); border-radius: 12px; background: #e9ece4; }
.auth-tabs button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: .88rem; font-weight: 700; }
.auth-tabs button.is-active { background: var(--card); color: var(--forest-deep); box-shadow: 0 1px 4px rgb(21 42 32 / 12%); }
#auth-form { display: grid; gap: 1rem; margin: 0; }
label { display: grid; gap: .42rem; color: #405149; font-size: .84rem; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: .68rem .78rem;
  border: 1px solid #cbd5cc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: .94rem;
}
input::placeholder, textarea::placeholder { color: #8a9890; }
input[type="checkbox"] { width: 17px; min-height: 17px; height: 17px; padding: 0; accent-color: var(--forest-soft); }
input[type="file"] { min-height: auto; padding: .5rem; }
.auth-message { min-height: 1.5em; margin: 0; color: var(--muted); font-size: .84rem; }
.auth-message[data-tone="error"] { color: var(--danger); }
.auth-message[data-tone="success"] { color: var(--forest-soft); }
.auth-submit { width: 100%; min-height: 48px; margin-top: .15rem; }
.auth-resend { justify-self: center; }
.auth-footnote { display: flex; align-items: flex-start; gap: .65rem; margin-top: 1.5rem; color: var(--muted); font-size: .76rem; }
.auth-footnote .status-dot { margin-top: .32rem; }
.auth-art {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: clamp(2rem, 6vw, 6rem);
  background: var(--forest);
  color: #edf2e8;
}
.auth-art::before, .auth-art::after { position: absolute; z-index: 0; border: 1px solid rgb(226 236 219 / 23%); border-radius: 50%; content: ""; }
.auth-art::before { width: min(72vw, 780px); aspect-ratio: 1; right: -12%; top: 7%; }
.auth-art::after { width: min(53vw, 570px); aspect-ratio: 1; right: -1%; top: 18%; }
.auth-art p, .auth-art span, .chart-line { position: relative; z-index: 1; }
.auth-art p { margin: 0 0 1rem; color: #f1f1e5; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.5rem, 8vw, 7rem); letter-spacing: -.06em; line-height: .87; }
.auth-art span { color: #b6c8b7; font-size: .7rem; font-weight: 700; letter-spacing: .16em; }
.chart-line { position: absolute; top: 43%; left: 4%; width: 88%; height: 1px; background: rgb(230 238 222 / 35%); transform: rotate(-18deg); transform-origin: center; }

.shell { display: grid; min-height: 100vh; grid-template-columns: 250px minmax(0, 1fr); }
.rail { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 1.65rem 1.15rem 1.2rem; background: var(--forest-deep); color: #eff2e8; }
.brand { display: inline-flex; align-items: center; gap: .78rem; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgb(218 233 215 / 47%); border-radius: 12px; color: #f2efe3; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.18rem; font-weight: 500; letter-spacing: -.02em; }
.brand small { margin-top: .08rem; color: #b5c8b6; font-size: .6rem; font-weight: 700; letter-spacing: .17em; }
.rail-label { margin: 3.2rem .7rem .65rem; color: #91a79a; font-size: .66rem; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
.nav { display: grid; gap: .3rem; }
.nav-item { display: flex; min-height: 45px; align-items: center; gap: .75rem; padding: .55rem .65rem; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #c8d4ca; font-size: .84rem; text-align: left; transition: background-color .16s ease, color .16s ease; }
.nav-item span { width: 1.45rem; color: #81998a; font-size: .66rem; font-weight: 700; }
.nav-item:hover { background: rgb(255 255 255 / 7%); color: #fff; }
.nav-item.is-active { border-color: rgb(223 235 214 / 16%); background: #294b3d; color: #fff; }
.nav-item.is-active span { color: #d4c49b; }
.rail-bottom { display: flex; align-items: center; gap: .7rem; margin-top: auto; padding: .9rem .6rem .2rem; border-top: 1px solid rgb(232 238 228 / 12%); }
.rail-bottom strong, .rail-bottom small { display: block; }
.rail-bottom strong { font-size: .78rem; font-weight: 650; }
.rail-bottom small { color: #9aafa1; font-size: .68rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #a6c98f; box-shadow: 0 0 0 4px rgb(166 201 143 / 14%); }
.rail-bottom:not([data-connected="true"]) .status-dot { background: #c7a26d; }

.main-column { min-width: 0; padding: 0 clamp(1rem, 3.2vw, 3.4rem) 2rem; }
.topbar { display: flex; min-height: 116px; align-items: center; justify-content: space-between; gap: 1.5rem; border-bottom: 1px solid var(--line); }
.topbar .eyebrow { margin-bottom: .35rem; }
.topbar .eyebrow span { margin: 0 .35rem; color: #b1bcb2; }
.topbar h1 { margin: 0; font-size: clamp(1.65rem, 2.7vw, 2.25rem); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; }
.tenant-control { display: flex; min-width: 165px; align-items: center; gap: .55rem; color: var(--muted); font-size: .75rem; }
.tenant-control select { min-height: 38px; padding: .42rem .6rem; font-size: .82rem; }
.user-chip { display: flex; min-width: 0; align-items: center; gap: .65rem; }
.user-chip strong, .user-chip small { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: .78rem; }
.user-chip small { color: var(--muted); font-size: .68rem; }
.user-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 1px solid #cbd8ca; border-radius: 50%; background: var(--sage); color: var(--forest); font-family: Georgia, "Times New Roman", serif; }
.notice { margin: .8rem 0; padding: .65rem .8rem; border-left: 3px solid #b7c7b3; color: var(--muted); font-size: .82rem; }
.notice[data-tone="success"] { border-color: #5c866a; color: #315e40; }
.notice[data-tone="error"] { border-color: var(--danger); color: var(--danger); }
#workspace { padding-top: 1.7rem; }
.view { display: none; }
.view.is-visible { display: block; animation: enter .2s ease-out; }
@keyframes enter { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.intro-row, .section-heading-row, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.intro-row { margin-bottom: 1.7rem; }
.intro-row > div { max-width: 47rem; }
.intro-row .button { flex: 0 0 auto; }
.section-intro { margin: .2rem 0 1.4rem; }
.section-heading-row { align-items: center; }
.section-heading-row > div:first-child { margin-bottom: 1rem; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1.05rem; }
.metric-card { min-height: 142px; padding: 1.2rem 1.35rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: 0 4px 15px rgb(37 55 45 / 3%); }
.metric-card span { display: block; color: var(--muted); font-size: .79rem; font-weight: 700; }
.metric-card strong { display: block; margin: .3rem 0 .05rem; color: var(--forest); font-family: Georgia, "Times New Roman", serif; font-size: 2.6rem; font-weight: 500; letter-spacing: -.06em; line-height: 1.08; }
.metric-card small { color: #849087; font-size: .72rem; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 1rem; align-items: start; }
.import-grid { grid-template-columns: minmax(0, 1.05fr) minmax(280px, .95fr); }
.people-grid { grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); }
.export-grid, .access-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel, .note-card { min-width: 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: 0 4px 18px rgb(37 55 45 / 3%); }
.panel-heading { align-items: center; margin-bottom: 1rem; }
.panel-heading .eyebrow { margin-bottom: .2rem; }
.panel-heading h3 { margin: 0; }
.note-card { background: var(--sage); }
.note-card h3 { max-width: 15ch; font-size: 1.65rem; }
.note-card p:not(.eyebrow) { color: #52645a; font-size: .87rem; }
.scope-list, .member-scopes { display: flex; flex-wrap: wrap; gap: .4rem; }
.scope-tag { display: inline-flex; align-items: center; padding: .27rem .55rem; border: 1px solid #ccdacb; border-radius: 999px; background: #f4f7f0; color: #38584a; font-size: .68rem; font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .75rem .55rem; border-bottom: 1px solid #e7ebe4; vertical-align: top; }
th { color: #718078; font-size: .66rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { color: #34443b; font-size: .81rem; }
tbody tr:last-child td { border-bottom: 0; }
.count-chip { display: grid; min-width: 32px; height: 32px; place-items: center; padding: 0 .45rem; border-radius: 50px; background: #edf2e9; color: var(--forest); font-size: .75rem; font-weight: 750; }
.state-pill { display: inline-block; padding: .25rem .55rem; border-radius: 999px; background: #edf0e8; color: #5e6b62; font-size: .68rem; font-weight: 750; text-transform: capitalize; }
.state-pill[data-state="completed"], .state-pill[data-state="active"] { background: #e2eee3; color: #386344; }
.state-pill[data-state="failed"], .state-pill[data-state="revoked"] { background: #f5e6e2; color: #8e473d; }
.state-pill[data-state="processing"], .state-pill[data-state="queued"], .state-pill[data-state="pending"] { background: #f4ead9; color: #846037; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: .45rem; padding: .58rem .9rem; border: 1px solid transparent; border-radius: 8px; font-size: .8rem; font-weight: 750; line-height: 1.2; text-decoration: none; transition: background-color .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--forest); color: #fff; }
.button-primary:hover { background: #244d3f; }
.button-quiet { border-color: #cfd9cf; background: transparent; color: var(--forest); }
.button-quiet:hover { border-color: #aabdaf; background: #edf2e9; }
.text-button, .link-button { padding: .25rem .1rem; border: 0; background: none; color: #3e7159; font-size: .77rem; font-weight: 750; text-align: left; }
.text-button:hover, .link-button:hover { color: var(--forest-deep); text-decoration: underline; text-underline-offset: 3px; }
.danger-text { color: var(--danger); }
.form-panel { display: grid; align-content: start; gap: .95rem; margin: 0; }
.form-panel .eyebrow, .form-panel h3 { margin-bottom: -.35rem; }
.inline-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .75rem; margin: .35rem 0 1rem; padding-bottom: 1rem; border-bottom: 1px solid #e7ebe4; }
.inline-form button { grid-column: 1 / -1; justify-self: start; }
.file-drop { display: flex; min-height: 185px; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; padding: 1.25rem; border: 1px dashed #aabcae; border-radius: 10px; background: #f5f8f1; color: var(--forest); text-align: center; cursor: pointer; }
.file-drop small { color: var(--muted); font-size: .75rem; font-weight: 500; }
.file-drop input { max-width: 100%; margin-top: .55rem; font-size: .72rem; }
.file-icon { display: grid; width: 36px; height: 36px; place-items: center; margin-bottom: .3rem; border-radius: 50%; background: var(--sage); color: var(--forest); font-size: 1.3rem; }
.file-summary { min-height: 1.3em; overflow-wrap: anywhere; color: var(--muted); font-size: .75rem; }
.check-row { display: flex; align-items: center; gap: .55rem; }
.check-row input { flex: 0 0 auto; }
.guidance-panel { background: #eff2e9; }
.guidance-panel h3 { max-width: 22ch; margin-bottom: 1.15rem; }
.format-list { display: grid; gap: .6rem; margin: 0 0 1.15rem; padding: 0; list-style: none; }
.format-list li { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .55rem; border-bottom: 1px solid #dce3d9; font-size: .8rem; }
.format-list li span { color: var(--muted); text-align: right; }
.callout { margin-top: .8rem; padding: .8rem; border-left: 3px solid var(--accent); background: #fbf6ec; font-size: .78rem; }
.callout p { margin: .25rem 0 0; color: #6a6b5e; }
.callout-muted { border-color: #a8b6aa; background: #e8eee6; }
.import-result { margin-top: 1rem; }
pre { max-width: 100%; overflow: auto; padding: .9rem; border-radius: 8px; background: #f0f2eb; color: #34443b; font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-panel { min-height: 280px; }
.empty-state { display: grid; min-height: 240px; align-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-state > span { color: #9aaf9e; font-size: 2.3rem; }
.empty-state strong { margin-top: .55rem; color: var(--forest); font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; font-weight: 500; }
.empty-state p { margin: .3rem 0 0; font-size: .8rem; }
.interaction-list { display: grid; gap: .55rem; }
.interaction-item { padding: .75rem; border: 1px solid #e4e9e1; border-radius: 8px; background: #fbfcf8; }
.interaction-item p { margin: .45rem 0 0; color: #48594f; font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.interaction-meta { display: flex; justify-content: space-between; gap: .8rem; color: var(--muted); font-size: .68rem; }
.subheading { margin: 1.1rem 0 .55rem; }
.manual-note { display: grid; gap: .7rem; margin: 1rem 0 0; padding-top: .85rem; border-top: 1px solid #e5e9e2; }
.manual-note input, .manual-note textarea { width: 100%; }
.manual-note textarea { min-height: 86px; resize: vertical; }
.manual-note button { justify-self: start; }
.scope-fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .8rem; margin: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 8px; }
.scope-fieldset legend { padding: 0 .3rem; color: #53635a; font-size: .74rem; font-weight: 700; }
.scope-fieldset label { display: flex; align-items: center; gap: .45rem; font-size: .76rem; font-weight: 550; }
.scope-fieldset label input { flex: 0 0 auto; }
.private-row { display: grid; gap: .55rem; padding-top: .7rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .74rem; }
.row-actions { display: flex; gap: .55rem; }
.membership-list { display: grid; gap: .65rem; }
.member-card { padding: .85rem; border: 1px solid #e2e8df; border-radius: 9px; background: #fff; }
.member-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .55rem; }
.member-head strong, .member-head small { display: block; overflow-wrap: anywhere; }
.member-head strong { color: var(--forest-deep); font-size: .82rem; }
.member-head small { margin-top: .18rem; color: var(--muted); font-size: .68rem; }
.member-actions { display: flex; gap: 1rem; margin-top: .6rem; }
.scope-editor { display: grid; gap: .75rem; margin: .6rem 0 0; padding-top: .65rem; border-top: 1px solid #e7ebe4; }
.scope-editor .scope-fieldset { grid-template-columns: 1fr 1fr; }
.scope-editor button { justify-self: start; }
.footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding: 1rem .1rem 0; border-top: 1px solid var(--line); color: #7c8980; font-size: .68rem; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 215px minmax(0, 1fr); }
  .rail { padding-inline: .9rem; }
  .topbar { align-items: flex-start; flex-direction: column; justify-content: center; padding: 1.1rem 0; }
  .top-actions { width: 100%; justify-content: space-between; }
  .content-grid, .people-grid, .import-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .auth-gate { grid-template-columns: 1fr; }
  .auth-card { width: 100%; max-width: 520px; padding: 1.4rem 1.15rem 2rem; }
  .auth-brand { margin-bottom: 2rem; }
  .auth-art { display: none; }
  .shell { display: block; }
  .rail { position: static; width: 100%; height: auto; padding: .7rem .85rem; }
  .rail .brand { margin-bottom: .65rem; }
  .rail-label, .rail-bottom { display: none; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem; }
  .nav-item { min-height: 38px; justify-content: center; gap: .35rem; padding: .35rem; font-size: .7rem; }
  .nav-item span { display: none; }
  .main-column { padding: 0 .9rem 1.2rem; }
  .topbar { min-height: auto; gap: .8rem; padding: 1rem 0; }
  .top-actions { align-items: flex-start; flex-wrap: wrap; }
  .tenant-control { flex: 1 1 100%; }
  .user-chip { flex: 1; }
  .user-chip strong { max-width: 190px; }
  #workspace { padding-top: .9rem; }
  .intro-row, .section-heading-row { align-items: stretch; flex-direction: column; }
  .intro-row .button { align-self: flex-start; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .export-grid, .access-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form button { grid-column: auto; }
  .row-actions { flex-wrap: wrap; }
  .footer { flex-direction: column; gap: .25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
