/* Bundlr 2 design system.
   Identity: calm paper-and-ink with a spruce accent and a clay "signature" highlight.
   Type scale (minor third, base 15px): 12.5 / 13.5 / 15 / 18 / 21.5 / 26 / 31. Spacing on a 4px grid. */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --fs-xs: 12.5px; --fs-sm: 13.5px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 21.5px; --fs-2xl: 26px; --fs-3xl: 31px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --nav-w: 232px; --top-h: 58px;

  --bg: #f5f3ee; --surface: #ffffff; --surface-2: #faf8f4; --surface-3: #f0ede6;
  --border: #e4dfd5; --border-strong: #d1c9ba;
  --text: #1b232e; --text-2: #4e5966; --text-3: #78828d;
  --accent: #0f6b66; --accent-hover: #0b5753; --accent-soft: #e2efed; --on-accent: #ffffff;
  --clay: #c8643b; --clay-soft: #f8e8df;
  --ok: #2c7a4b; --ok-soft: #e3f1e8; --warn: #9a6200; --warn-soft: #fbf0d9; --danger: #b2372e; --danger-soft: #f9e4e1;
  --info: #2f5f9e; --info-soft: #e5edf8;
  --focus: 0 0 0 3px rgba(15, 107, 102, .32);
  --shadow-1: 0 1px 2px rgba(27, 35, 46, .06), 0 1px 1px rgba(27, 35, 46, .03);
  --shadow-2: 0 10px 30px rgba(27, 35, 46, .14), 0 2px 6px rgba(27, 35, 46, .06);
  --scrim: rgba(18, 24, 30, .42);
  --page-bg: #e9e5dc;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1316; --surface: #151c20; --surface-2: #192226; --surface-3: #1f292e;
  --border: #26323a; --border-strong: #35444e;
  --text: #e6e9e5; --text-2: #a5b0b7; --text-3: #7f8b94;
  --accent: #3eb2a5; --accent-hover: #5cc5b9; --accent-soft: #143430; --on-accent: #04211d;
  --clay: #e48b62; --clay-soft: #3a2419;
  --ok: #5cc08a; --ok-soft: #173325; --warn: #e0ad4a; --warn-soft: #3a2d12; --danger: #f07c71; --danger-soft: #3d1c19;
  --info: #7fb0f0; --info-soft: #182a41;
  --focus: 0 0 0 3px rgba(62, 178, 165, .4);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 12px 34px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .6);
  --page-bg: #0a0e10;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0e1316; --surface: #151c20; --surface-2: #192226; --surface-3: #1f292e;
    --border: #26323a; --border-strong: #35444e;
    --text: #e6e9e5; --text-2: #a5b0b7; --text-3: #7f8b94;
    --accent: #3eb2a5; --accent-hover: #5cc5b9; --accent-soft: #143430; --on-accent: #04211d;
    --clay: #e48b62; --clay-soft: #3a2419;
    --ok: #5cc08a; --ok-soft: #173325; --warn: #e0ad4a; --warn-soft: #3a2d12; --danger: #f07c71; --danger-soft: #3d1c19;
    --info: #7fb0f0; --info-soft: #182a41;
    --focus: 0 0 0 3px rgba(62, 178, 165, .4);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 12px 34px rgba(0, 0, 0, .5);
    --scrim: rgba(0, 0, 0, .6);
    --page-bg: #0a0e10;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 var(--fs-md)/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 650; letter-spacing: -0.012em; }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); } h4 { font-size: var(--fs-md); }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img, svg { vertical-align: middle; }
.ico { width: 18px; height: 18px; flex: none; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .9em; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text-2); background: var(--surface); font-size: 11px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: var(--r-sm); text-decoration: none; }
.skip-link:focus { top: 12px; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: var(--fs-sm); }
.hint { color: var(--text-3); font-size: var(--fs-sm); margin: 4px 0 0; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { margin-left: auto; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; } .mb { margin-bottom: 16px; }

/* ---------- brand ---------- */
.lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.lockup img { border-radius: 10px; }
.wordmark { height: 26px; width: auto; color: var(--text); }
.wordmark-r { stroke: var(--accent); }
.lockup-sm .wordmark { height: 20px; }
.lockup-sm img { border-radius: 8px; }

/* ---------- buttons ---------- */
.btn { --b: var(--border-strong); display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 14px;
  font: 550 var(--fs-sm)/1.2 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--b); border-radius: var(--r-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-clay { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn-clay:hover { filter: brightness(1.05); background: var(--clay); color: #fff; border-color: var(--clay); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: var(--fs-xs); }
.btn-lg { min-height: 44px; padding: 10px 20px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.icon-btn svg { width: 20px; height: 20px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.field .opt { font-weight: 400; color: var(--text-3); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; font: inherit; font-size: var(--fs-md); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type="color"] { width: 44px; height: 36px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); padding: 2px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: var(--fs-sm); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px 14px; margin: 0; }
legend { font-weight: 650; font-size: var(--fs-sm); padding: 0 6px; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: var(--r-sm); gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 5px; font: 550 var(--fs-sm) var(--font); color: var(--text-2); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented button:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- alerts, pills ---------- */
.alert { padding: 10px 14px; border-radius: var(--r-sm); font-size: var(--fs-sm); border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--info-soft); color: var(--info); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-clay { background: var(--clay-soft); color: var(--clay); }
.pill-info { background: var(--info-soft); color: var(--info); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.tag:hover { color: var(--accent-hover); }
.tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }

/* ---------- auth pages ---------- */
body.auth { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; }
.auth-brand { background: linear-gradient(160deg, #0f6b66 0%, #0b4f4b 60%, #0a3f3c 100%); color: #eaf4f2; position: relative; overflow: hidden; }
.auth-brand-inner { position: sticky; top: 0; padding: 56px 48px; min-height: 100vh; display: flex; flex-direction: column; }
.auth-brand .wordmark { color: #fff; height: 30px; }
.auth-brand .wordmark-r { stroke: #f2b08f; }
.auth-tagline { font-size: var(--fs-3xl); font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin: 64px 0 24px; max-width: 17ch; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; max-width: 34ch; color: #cfe5e1; }
.auth-points li { padding-left: 26px; position: relative; }
.auth-points li::before { content: ""; position: absolute; left: 0; top: .45em; width: 12px; height: 8px; border-left: 2px solid #f2b08f; border-bottom: 2px solid #f2b08f; transform: rotate(-45deg); }
.auth-sheets { position: absolute; right: -60px; bottom: -40px; width: 300px; height: 360px; }
.auth-sheets span { position: absolute; inset: 0; border-radius: 18px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12); }
.auth-sheets span:nth-child(2) { transform: rotate(-7deg) translate(-26px, 10px); }
.auth-sheets span:nth-child(3) { transform: rotate(-14deg) translate(-52px, 22px); background: rgba(255, 255, 255, .1); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px 24px; gap: 32px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 32px; box-shadow: var(--shadow-1); }
.auth-card h1 { font-size: var(--fs-2xl); }
.auth-card-logo { display: none; margin-bottom: 20px; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card-logo { display: inline-flex; }
  .auth-card { padding: 24px; }
}

/* ---------- footer badges ---------- */
.site-footer { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: center; padding: 18px 16px 22px; }
.badge { display: inline-block; line-height: 0; border-radius: 8px; opacity: .92; }
.badge:hover { opacity: 1; }
.badge img { width: 183px; height: 32px; }
.badge-dark { display: none; }
[data-theme="dark"] .badge-light { display: none; }
[data-theme="dark"] .badge-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .badge-light { display: none; }
  [data-theme="auto"] .badge-dark { display: inline; }
}

/* ---------- app shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-rows: var(--top-h) 1fr; }
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 0 16px 0 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-logo { width: calc(var(--nav-w) - 34px); flex: none; }
.nav-toggle { display: none; }
.search { position: relative; flex: 1 1 auto; max-width: 560px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 36px; padding-right: 36px; background: var(--surface-2); border-color: var(--border); min-height: 38px; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: none; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; color: var(--text); font: inherit; font-size: var(--fs-sm); }
.avatar-btn:hover { background: var(--surface-3); }
.avatar-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--clay-soft); color: var(--clay); font-weight: 700; font-size: 13px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 6px; }
.menu-list a, .menu-list button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); color: var(--text); text-decoration: none; font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: left; }
.menu-list a:hover, .menu-list button:hover, .menu-list a:focus-visible, .menu-list button:focus-visible { background: var(--surface-3); outline: none; }
.menu-list .danger { color: var(--danger); }
.menu-list form { margin: 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: grid; }
.menu-head span { color: var(--text-3); font-size: var(--fs-xs); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

.sidenav { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); display: flex; flex-direction: column; padding: 14px 12px; border-right: 1px solid var(--border); background: var(--surface-2); overflow-y: auto; }
.sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-weight: 550; font-size: var(--fs-md); }
.sidenav a:hover { background: var(--surface-3); color: var(--text); }
.sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sidenav a:focus-visible { outline: none; box-shadow: var(--focus); }
.nav-icon { width: 20px; height: 20px; flex: none; }
.quota { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-xs); color: var(--text-2); }
.quota strong { color: var(--text); font-size: var(--fs-sm); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 8px 0 4px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.meter.warn > i { background: var(--warn); } .meter.full > i { background: var(--danger); }
.nav-scrim { position: fixed; inset: var(--top-h) 0 0 0; background: var(--scrim); z-index: 24; }

.workspace { min-width: 0; display: flex; flex-direction: column; outline: none; }
.view { flex: 1 0 auto; padding: 26px 32px 40px; max-width: 1320px; width: 100%; margin: 0 auto; }
.view-wide { max-width: none; }
.loading { color: var(--text-3); padding: 40px 0; text-align: center; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .lede { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: var(--fs-sm); color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--text-3); }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-grid; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar-logo { width: auto; }
  .topbar-logo .wordmark { display: none; }
  .sidenav { position: fixed; top: var(--top-h); left: 0; bottom: 0; width: min(280px, 84vw); height: auto; z-index: 25; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-2); }
  .shell.nav-open .sidenav { transform: none; }
  .view { padding: 18px 16px 32px; }
  .avatar-name { display: none; }
  .search kbd { display: none; }
}
@media (max-width: 520px) {
  .page-head { flex-direction: column; }
  .page-actions { width: 100%; }
  h1 { font-size: var(--fs-xl); }
}

/* ---------- cards, panels, tabs ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: var(--fs-md); }
.card-body { padding: 16px 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; color: var(--text-2); font: 550 var(--fs-sm) var(--font); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:focus-visible, .tabs button:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.split-left { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .split, .split-left { grid-template-columns: 1fr; } }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: var(--fs-sm); }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- tables / lists ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
table.list { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.list th { text-align: left; font-weight: 600; color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list tr.drop-target { background: var(--accent-soft); }
.name-cell { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.name-cell a { color: var(--text); font-weight: 550; text-decoration: none; }
.name-cell a:hover { color: var(--accent); text-decoration: underline; }
.file-ico { width: 34px; height: 40px; flex: none; }
.fi-page { fill: var(--surface); stroke: var(--border-strong); }
.fi-fold { fill: none; stroke: var(--border-strong); }
.folder-ico { width: 34px; height: 30px; flex: none; color: var(--clay); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.snippet { color: var(--text-2); font-size: var(--fs-xs); margin-top: 2px; }
.snippet mark { background: var(--clay-soft); color: inherit; padding: 0 2px; border-radius: 3px; }
@media (max-width: 720px) {
  table.list .hide-sm { display: none; }
  .name-cell { min-width: 0; }
}

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 48px 24px; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); }
.empty svg.empty-art { width: 96px; height: 80px; margin-bottom: 14px; color: var(--text-3); }
.empty-art .a-accent { fill: var(--accent); } .empty-art .a-clay { fill: var(--clay); }
.empty-art .a-accent-s { stroke: var(--accent); } .empty-art .a-clay-s { stroke: var(--clay); }
.empty h2, .empty h3 { font-size: var(--fs-lg); margin-bottom: 6px; }
.empty p { color: var(--text-2); max-width: 46ch; margin: 0 auto 16px; }
.empty .row { justify-content: center; }
.empty-sm { padding: 22px 16px; }
.empty-sm p { margin-bottom: 10px; font-size: var(--fs-sm); }

/* ---------- dropzone & uploads ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 22px; text-align: center; color: var(--text-2); background: var(--surface-2); transition: border-color .12s, background .12s; }
.dropzone.over, body.dragging .dropzone { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); border: 3px dashed var(--accent); pointer-events: none; font-size: var(--fs-xl); font-weight: 650; color: var(--accent); }
.uploads { display: grid; gap: 6px; margin-bottom: 14px; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-sm); }
.upload-row .meter { grid-column: 1 / -1; margin: 0; }

/* ---------- dialog ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 80; display: grid; place-items: center; padding: 16px; animation: fade .12s ease; }
.dialog { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); display: flex; flex-direction: column; }
.dialog-wide { width: min(980px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h2 { margin: 0; font-size: var(--fs-lg); }
.dialog-body { padding: 18px 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); position: sticky; bottom: 0; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--text); color: var(--bg); box-shadow: var(--shadow-2); font-size: var(--fs-sm); animation: rise .18s ease; }
.toast-error { background: var(--danger); color: #fff; }
.toast a { color: inherit; font-weight: 650; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; opacity: .8; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- document view ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .doc-layout { grid-template-columns: 1fr; } }
.preview { background: var(--page-bg); border-radius: var(--r-lg); padding: 18px; min-height: 320px; display: grid; gap: 14px; justify-items: center; overflow: auto; max-height: calc(100vh - 220px); }
.preview canvas, .preview img.preview-img { max-width: 100%; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .16); border-radius: 2px; }
.preview-msg { align-self: center; text-align: center; color: var(--text-2); max-width: 44ch; }
.side-panel { display: grid; gap: 16px; }
.side-panel .card-body { font-size: var(--fs-sm); }
.version-list, .activity-list, .link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.version-list li, .activity-list li, .link-list li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.version-list li:last-child, .activity-list li:last-child, .link-list li:last-child { border-bottom: 0; }
.activity-list time { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-top: 6px; flex: none; }
.dot-accent { background: var(--accent); } .dot-clay { background: var(--clay); } .dot-danger { background: var(--danger); }

/* ---------- bundle builder ---------- */
.builder { display: grid; grid-template-columns: 290px minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
@media (max-width: 1280px) { .builder { grid-template-columns: 300px minmax(0, 1fr); } .builder-options { grid-column: 1 / -1; } }
@media (max-width: 820px) { .builder { grid-template-columns: 1fr; } }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow: auto; }
.picker-list li { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.picker-list li:last-child { border-bottom: 0; }
.picker-list .file-ico { width: 24px; height: 28px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: item; }
.items > li { min-width: 0; }
.item .row { flex-wrap: nowrap; gap: 2px; flex: none; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-1); counter-increment: item; }
.item:focus-within { border-color: var(--accent); }
.item.dragging { opacity: .5; }
.item.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.item.drop-after { box-shadow: 0 3px 0 var(--accent); }
.item.problem { border-color: var(--danger); background: var(--danger-soft); }
.item-num::before { content: counter(item); }
.item-num { width: 22px; text-align: center; color: var(--text-3); font-size: var(--fs-xs); font-weight: 650; }
.grip { cursor: grab; color: var(--text-3); padding: 4px; border: 0; background: none; border-radius: 4px; display: grid; place-items: center; }
.grip:focus-visible { outline: none; box-shadow: var(--focus); }
.grip svg { width: 16px; height: 16px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: var(--fs-sm); }
.item-meta { color: var(--text-3); font-size: var(--fs-xs); }
.item-title-page .file-ico { color: var(--clay); }
.items-foot { display: flex; justify-content: space-between; color: var(--text-2); font-size: var(--fs-sm); margin-top: 12px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tpl-card { border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 10px; background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: var(--text); }
.tpl-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--focus); }
.tpl-card strong { display: block; font-size: var(--fs-sm); }
.tpl-card span { color: var(--text-3); font-size: var(--fs-xs); }
.tpl-thumb { height: 86px; border-radius: 4px; background: #fff; border: 1px solid var(--border); margin-bottom: 8px; display: grid; place-items: center; color: #1b232e; font-weight: 700; font-size: 11px; text-align: center; padding: 6px; }

/* ---------- page picker ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.thumb { position: relative; border: 2px solid var(--border); border-radius: var(--r-md); padding: 6px; background: var(--surface-2); cursor: pointer; text-align: center; font: inherit; color: var(--text-2); font-size: var(--fs-xs); }
.thumb canvas { width: 100%; height: auto; background: #fff; display: block; margin-bottom: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.thumb[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.thumb[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; }
.thumb:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- PDF placement editor ---------- */
.editor { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; }
  .editor .tools { order: 2; position: static; }
}
.bar-next { display: none; }
@media (max-width: 960px) { .bar-next { display: inline-flex; } }
.tools { position: sticky; top: calc(var(--top-h) + 16px); display: grid; gap: 14px; }
body.external .tools { top: 16px; }
.tool-group { display: grid; gap: 6px; }
.tool-group > .label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.tool { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: 550 var(--fs-sm) var(--font); cursor: pointer; text-align: left; }
.tool:hover { border-color: var(--accent); }
.tool[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tool:focus-visible { outline: none; box-shadow: var(--focus); }
.tool img { height: 22px; max-width: 90px; object-fit: contain; background: #fff; border-radius: 3px; }
.tool .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.viewer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 12px; position: sticky; top: calc(var(--top-h) + 8px); z-index: 5; }
body.external .viewer-bar { top: 8px; }
.viewer-bar .page-info { font-size: var(--fs-sm); color: var(--text-2); min-width: 90px; text-align: center; }
.stage { background: var(--page-bg); border-radius: var(--r-lg); padding: 18px; overflow: auto; display: grid; justify-items: center; gap: 18px; min-height: 420px; }
.page-wrap { position: relative; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .18); }
.page-wrap canvas { display: block; }
.page-wrap.placing { cursor: crosshair; }
.page-label { position: absolute; left: -2px; top: -22px; font-size: var(--fs-xs); color: var(--text-3); }
.mark { position: absolute; border: 1.5px dashed transparent; border-radius: 3px; display: grid; place-items: center; cursor: move; touch-action: none; user-select: none; }
.mark:hover, .mark.selected, .mark:focus-visible { border-color: var(--accent); background: rgba(15, 107, 102, .06); outline: none; }
.mark img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.mark .mark-text { white-space: nowrap; overflow: hidden; width: 100%; padding: 0 2px; line-height: 1; color: #111827; font-family: Helvetica, Arial, sans-serif; }
.mark .mark-x { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; display: none; place-items: center; }
.mark.selected .mark-x, .mark:hover .mark-x, .mark:focus-within .mark-x { display: grid; }
.mark .resize { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: var(--accent); cursor: nwse-resize; display: none; }
.mark.selected .resize, .mark:hover .resize { display: block; }
.field-box { position: absolute; border: 1.5px solid var(--clay); background: color-mix(in srgb, var(--clay) 13%, transparent); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 650; color: var(--clay); cursor: pointer; text-align: center; padding: 2px; overflow: hidden; }
.field-box.filled { background: transparent; border-style: dashed; border-color: color-mix(in srgb, var(--clay) 50%, transparent); }
.field-box.design { cursor: move; touch-action: none; }
.field-box.selected { box-shadow: 0 0 0 2px var(--clay); }
.field-box .mark-x { position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 12px; cursor: pointer; display: none; place-items: center; }
.field-box.selected .mark-x, .field-box:hover .mark-x { display: grid; }
.field-box img { width: 100%; height: 100%; object-fit: contain; }
.field-box input { width: 100%; height: 100%; border: 0; background: transparent; font-size: 12px; color: #111827; padding: 0 4px; min-height: 0; }
.field-box input:focus { box-shadow: none; }
.field-box.required:not(.filled)::after { content: "*"; position: absolute; top: 0; right: 4px; color: var(--clay); }
.signer-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); }

/* ---------- signature pad ---------- */
.sigpad { display: grid; gap: 10px; }
.sigpad-surface { position: relative; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: #fff; height: 170px; touch-action: none; }
.sigpad-surface canvas { width: 100%; height: 100%; display: block; cursor: crosshair; border-radius: inherit; }
.sigpad-surface .baseline { position: absolute; left: 24px; right: 24px; bottom: 42px; border-bottom: 1px solid #d7d2c8; pointer-events: none; }
.sigpad-surface .ph { position: absolute; left: 24px; bottom: 18px; color: #9aa1a8; font-size: 12px; pointer-events: none; }
.sig-fonts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.sig-font { border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: #fff; color: #111827; padding: 8px 10px; font-size: 26px; cursor: pointer; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sig-font[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--focus); }
.sig-preview { background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); height: 110px; display: grid; place-items: center; }
.sig-preview img { max-height: 90px; max-width: 90%; }
.sig-preview.empty-sig { color: #8a929b; font-size: var(--fs-sm); }

/* ---------- envelopes / progress ---------- */
.steps { display: flex; gap: 0; list-style: none; padding: 0; margin: 0 0 22px; counter-reset: step; flex-wrap: wrap; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: var(--fs-sm); font-weight: 550; padding-right: 18px; }
.steps li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); font-size: 12px; }
.steps li[aria-current="step"] { color: var(--text); }
.steps li[aria-current="step"]::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.steps li.done::before { content: "✓"; background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.signer-row { display: grid; grid-template-columns: 28px 1fr 1fr auto; gap: 8px; align-items: center; }
.signer-row .swatch { width: 14px; height: 14px; border-radius: 4px; justify-self: center; }
@media (max-width: 620px) { .signer-row { grid-template-columns: 20px 1fr; } .signer-row > :nth-child(n+3) { grid-column: 2; } }
.progress-dots { display: inline-flex; gap: 4px; }
.progress-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.progress-dots i.signed { background: var(--ok); } .progress-dots i.viewed { background: var(--info); } .progress-dots i.sent { background: var(--warn); } .progress-dots i.declined { background: var(--danger); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 12px; }
.timeline li { position: relative; font-size: var(--fs-sm); }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

/* ---------- external pages ---------- */
body.external { min-height: 100vh; display: flex; flex-direction: column; }
.ext-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.ext-main { flex: 1; outline: none; }
.ext-main .view { max-width: 1240px; }
.ext-hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.ext-hero .from { color: var(--text-2); font-size: var(--fs-sm); }
.state-card { max-width: 520px; margin: 40px auto; text-align: center; }
.state-card .state-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; font-size: 28px; background: var(--accent-soft); color: var(--accent); }
.state-card .state-icon.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- misc ---------- */
.kbd-help { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: var(--fs-sm); }
.stat { display: grid; gap: 2px; }
.stat strong { font-size: var(--fs-xl); }
.stat span { color: var(--text-3); font-size: var(--fs-xs); }
.code-box { display: flex; gap: 8px; align-items: center; }
.code-box input { font-family: var(--font-mono); font-size: var(--fs-sm); }
.hash { font-family: var(--font-mono); font-size: 11.5px; overflow-wrap: anywhere; color: var(--text-2); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.audit-details { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); max-width: 360px; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .sidenav, .site-footer, .toasts { display: none !important; }
  .shell { display: block; }
}
