/* =====================================================================
   EDIDOC Tools – Design System
   Light and dark theme, one accent, calm surfaces, dense-but-readable.
   ===================================================================== */

:root {
  color-scheme: light;

  --font-sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;

  --bg: #f4f6fa;
  --bg-elevated: #ffffff;
  --bg-sunken: #eaeef5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --border: #dde3ec;
  --border-strong: #c8d1e0;

  --text: #17202e;
  --text-muted: #5b6678;
  --text-faint: #8a94a6;
  --text-inverse: #ffffff;

  --accent: #2f5fd0;
  --accent-strong: #24499f;
  --accent-soft: #e7edfb;
  --accent-softer: #f2f6fe;

  --ok: #0f7a4d;
  --ok-soft: #e3f5ec;
  --warn: #b26a00;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #0b6b8f;
  --info-soft: #e3f2f8;

  --l3: #5b4bd1;
  --l2: #8257e5;
  --l1: #0f7ba8;
  --l0: #0f7a4d;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.22);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --header-h: 58px;
  --status-h: 30px;
  --sidebar-w: 316px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e131b;
  --bg-elevated: #151c26;
  --bg-sunken: #0a0f16;
  --surface: #161e29;
  --surface-2: #1b2431;
  --surface-3: #222d3c;
  --border: #26313f;
  --border-strong: #364456;

  --text: #e8edf4;
  --text-muted: #a3afc0;
  --text-faint: #788598;
  --text-inverse: #0e131b;

  --accent: #7aa2ff;
  --accent-strong: #a9c2ff;
  --accent-soft: #1d2b47;
  --accent-softer: #16202f;

  --ok: #4cd08a;
  --ok-soft: #10261c;
  --warn: #f0b355;
  --warn-soft: #2a2113;
  --danger: #ff8a80;
  --danger-soft: #2c1917;
  --info: #6cc5e0;
  --info-soft: #12262e;

  --l3: #a99bff;
  --l2: #c3a6ff;
  --l1: #6cc5e0;
  --l0: #4cd08a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 0.75em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); color: var(--text); }

/* ------------------------------- shell ------------------------------ */

#app { height: 100%; }

.shell {
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--status-h);
  grid-template-columns: minmax(0, 1fr);
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
  margin-right: 2px;
  min-width: 0;
  background: none;
  border-top: none;
  border-left: none;
  border-bottom: none;
  cursor: pointer;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), #7b4bd6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 13.5px; font-weight: 650; letter-spacing: 0.01em; }
.brand-text span { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }

.doc-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.doc-title .name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.doc-title .dirty {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex: none;
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ------------------------------ buttons ----------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }

.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }

.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; border-radius: 7px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-3);
  border-radius: 10px;
  gap: 2px;
  border: 1px solid var(--border);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 11px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.segmented button svg { width: 14px; height: 14px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ------------------------------ layout ------------------------------ */

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  background: var(--bg);
}
.workspace.no-sidebar { grid-template-columns: minmax(0, 1fr); }

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
}

.sidebar-head {
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box svg {
  position: absolute;
  left: 9px;
  width: 15px; height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 30px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}
.search-box input:focus { background: var(--surface); }
.search-box kbd {
  position: absolute;
  right: 8px;
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--surface);
  pointer-events: none;
}

.tree-scroll { flex: 1; overflow: auto; padding: 8px 8px 24px; }

.main {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  scroll-behavior: smooth;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.statusbar .spacer { flex: 1; }
.statusbar .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.statusbar .chip svg { width: 12px; height: 12px; }
.statusbar .chip.ok { background: var(--ok-soft); color: var(--ok); }
.statusbar .chip.warn { background: var(--warn-soft); color: var(--warn); }
.statusbar .chip.err { background: var(--danger-soft); color: var(--danger); }

/* -------------------------------- tree ------------------------------ */

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 14px; padding-left: 8px; border-left: 1px dashed var(--border-strong); }

.tree-item { margin: 1px 0; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  position: relative;
  transition: background 0.12s var(--ease);
}
.tree-row:hover { background: var(--surface-3); }
.tree-row[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.tree-row[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.node-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-3);
  color: var(--text-muted);
}
.node-icon svg { width: 13px; height: 13px; }
.node-icon.l3 { background: color-mix(in srgb, var(--l3) 14%, transparent); color: var(--l3); }
.node-icon.l2 { background: color-mix(in srgb, var(--l2) 14%, transparent); color: var(--l2); }
.node-icon.l1 { background: color-mix(in srgb, var(--l1) 14%, transparent); color: var(--l1); }
.node-icon.l0 { background: color-mix(in srgb, var(--l0) 14%, transparent); color: var(--l0); }

.tree-label { min-width: 0; flex: 1; }
.tree-label b {
  display: block;
  font-weight: 550;
  font-size: 13.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-label span {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-badges { display: flex; gap: 4px; align-items: center; flex: none; }
.tree-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.tree-badge.attachment { background: var(--accent-soft); color: var(--accent-strong); }
.tree-badge.canceled { background: var(--danger-soft); color: var(--danger); }
.tree-row.canceled .tree-label b { text-decoration: line-through; opacity: 0.75; }

.tree-toggle {
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-faint);
  flex: none;
}
.tree-toggle:hover { background: var(--surface-3); color: var(--text); }
.tree-toggle svg { width: 12px; height: 12px; transition: transform 0.15s var(--ease); }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.tree-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
}
.tree-empty .btn { margin-top: 10px; }

.tree-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ------------------------------ content ----------------------------- */

.page {
  padding: 22px 26px 64px;
  max-width: 1180px;
  margin: 0 auto;
}
.page.wide { max-width: 1400px; }

.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 4px; }
.page-head .titles { min-width: 0; flex: 1; }
.page-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.page-title {
  font-size: 25px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0;
  overflow-wrap: anywhere;
}
.page-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 5px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.page-sub .kv { display: inline-flex; align-items: center; gap: 5px; }
.page-sub .kv svg { width: 13px; height: 13px; color: var(--text-faint); }
.page-actions { display: flex; gap: 6px; flex: none; align-items: center; }

.tabs {
  display: flex;
  gap: 2px;
  margin: 18px 0 18px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px 11px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-strong); font-weight: 650; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.tab svg { width: 15px; height: 15px; }
.tab .count {
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.tab[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent-strong); }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.section-head h3 { font-size: 13.5px; font-weight: 650; }
.section-head .hint { color: var(--text-faint); font-size: 12px; }
.section-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.section-body { padding: 16px; }
.section-body.flush { padding: 0; }
.section.collapsed .section-body { display: none; }

.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: inherit;
}
.section-toggle svg { width: 14px; height: 14px; color: var(--text-faint); transition: transform 0.15s var(--ease); }
.section.collapsed .section-toggle svg { transform: rotate(-90deg); }

/* ------------------------------- fields ----------------------------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 18px;
}
.field-grid.one { grid-template-columns: 1fr; }
.field-grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field > label, .field-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-muted);
  letter-spacing: 0.005em;
}
.field .required { color: var(--danger); font-weight: 700; }
.field .help {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  cursor: help;
  flex: none;
}
.field input[type="text"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.field textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.field input:disabled, .field select:disabled, .field textarea:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
}
.field .hint { font-size: 11.5px; color: var(--text-faint); }
.field .invalid, .field input.invalid { border-color: var(--danger); }

.readonly-value {
  font-size: 13.5px;
  padding: 7px 0;
  color: var(--text);
  overflow-wrap: anywhere;
}
.readonly-value.empty { color: var(--text-faint); font-style: italic; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  min-height: 34px;
  cursor: pointer;
}
.switch {
  position: relative;
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  flex: none;
  transition: background 0.15s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease);
}
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row input:checked + .switch { background: var(--ok); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------- value lists --------------------------- */

.value-list { display: flex; flex-direction: column; gap: 2px; }
.value-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  min-height: 40px;
}
.value-row:hover { background: var(--surface-2); }
.value-row .grow { flex: 1; min-width: 0; }
.value-row .title { font-size: 13.5px; font-weight: 550; overflow-wrap: anywhere; }
.value-row .meta { font-size: 11.5px; color: var(--text-faint); }
.value-row .actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.12s var(--ease); }
.value-row:hover .actions, .value-row:focus-within .actions { opacity: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.chip.accent { background: var(--accent-soft); color: var(--accent-strong); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip svg { width: 12px; height: 12px; }

.badge-layer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-layer.l3 { background: color-mix(in srgb, var(--l3) 14%, transparent); color: var(--l3); }
.badge-layer.l2 { background: color-mix(in srgb, var(--l2) 14%, transparent); color: var(--l2); }
.badge-layer.l1 { background: color-mix(in srgb, var(--l1) 14%, transparent); color: var(--l1); }
.badge-layer.l0 { background: color-mix(in srgb, var(--l0) 14%, transparent); color: var(--l0); }

.empty-state {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  color: var(--text-faint);
}
.empty-state .icon svg { width: 20px; height: 20px; }
.empty-state h4 { font-size: 14px; margin-bottom: 4px; color: var(--text); }
.empty-state p { font-size: 12.5px; max-width: 420px; margin: 0 auto 12px; }

/* ------------------------------ documents --------------------------- */

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.doc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.doc-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-card[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.doc-thumb {
  height: 132px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.doc-thumb img, .doc-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb .mime-icon { color: var(--text-faint); }
.doc-thumb .mime-icon svg { width: 34px; height: 34px; }
.doc-thumb .ext {
  position: absolute;
  bottom: 7px; right: 7px;
  background: color-mix(in srgb, var(--text) 72%, transparent);
  color: var(--bg-elevated);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
}
.doc-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.doc-card-body b { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.doc-card-body span { font-size: 11.5px; color: var(--text-faint); }

.preview-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  min-height: 420px;
  display: flex;
  flex-direction: column;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
}
.preview-toolbar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-toolbar .spacer { flex: 1; }
.preview-body { flex: 1; min-height: 0; background: var(--surface-3); display: flex; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; min-height: 460px; }
.preview-body img { max-width: 100%; max-height: 70vh; margin: auto; display: block; object-fit: contain; }
.preview-body pre {
  margin: 0;
  padding: 16px;
  width: 100%;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  white-space: pre-wrap;
  word-break: break-word;
}
.preview-body .unsupported { margin: auto; text-align: center; padding: 30px; color: var(--text-muted); }

/* ------------------------------- workflow --------------------------- */

.workflow-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) { .workflow-shell { grid-template-columns: 1fr; } }
.workflow-canvas {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
  max-height: 620px;
  padding: 4px;
}
.workflow-canvas svg { display: block; }
.wf-node rect { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; }
.wf-node.current rect { stroke: var(--accent); stroke-width: 2; fill: var(--accent-softer); }
.wf-node.finished rect { stroke: var(--ok); }
.wf-node.canceled rect { stroke: var(--danger); }
.wf-node text { font-family: var(--font-sans); font-size: 11.5px; font-weight: 600; fill: var(--text); }
.wf-node .sub { font-size: 9.5px; font-weight: 500; fill: var(--text-muted); }
.wf-node .state-dot { }
.wf-edge path { stroke: var(--border-strong); stroke-width: 1.6; fill: none; }
.wf-edge.active path { stroke: var(--accent); }
.wf-edge text {
  font-family: var(--font-sans);
  font-size: 9.5px;
  fill: var(--text-faint);
}
.wf-edge .wf-edge-label {
  fill: var(--text-muted);
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 0 0 14px;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 8px; top: 16px; bottom: 0;
  width: 1.5px;
  background: var(--border);
}
.timeline-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  margin-top: 3px;
  z-index: 1;
}
.timeline-dot.finished { border-color: var(--ok); background: var(--ok); }
.timeline-dot.processing { border-color: var(--accent); background: var(--accent); }
.timeline-dot.canceled { border-color: var(--danger); background: var(--danger); }
.timeline-body b { font-size: 12.8px; font-weight: 600; }
.timeline-body .meta { font-size: 11.5px; color: var(--text-faint); }
.timeline-body p { font-size: 12px; color: var(--text-muted); margin: 3px 0 0; }

/* -------------------------------- table ----------------------------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------- code ------------------------------ */

.code-view {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 260px);
  padding: 14px 16px;
  white-space: pre;
  tab-size: 2;
  color: var(--text);
}
.code-view .tok-tag { color: #2f5fd0; }
.code-view .tok-attr { color: #8257e5; }
.code-view .tok-value { color: #0f7a4d; }
.code-view .tok-comment { color: var(--text-faint); font-style: italic; }
[data-theme="dark"] .code-view .tok-tag { color: #7aa2ff; }
[data-theme="dark"] .code-view .tok-attr { color: #c3a6ff; }
[data-theme="dark"] .code-view .tok-value { color: #4cd08a; }

.xml-tree { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; }
.xml-tree .node { padding-left: 16px; position: relative; }
.xml-tree .node::before {
  content: "";
  position: absolute;
  left: 5px; top: 0; bottom: 0;
  border-left: 1px dashed var(--border-strong);
}
.xml-tree .node:last-child::before { bottom: 50%; }
.xml-tree .tag { color: var(--accent-strong); }
.xml-tree .attr-name { color: #8257e5; }
.xml-tree .attr-value { color: var(--ok); }
[data-theme="dark"] .xml-tree .attr-name { color: #c3a6ff; }
[data-theme="dark"] .xml-tree .attr-value { color: #4cd08a; }
.xml-tree .text { color: var(--text); }
.xml-tree .muted { color: var(--text-faint); }

/* -------------------------------- issues ---------------------------- */

.issue-list { display: flex; flex-direction: column; }
.issue {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: flex-start;
}
.issue:last-child { border-bottom: none; }
.issue:hover { background: var(--surface-2); }
.issue .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
}
.issue.error .dot { background: var(--danger); }
.issue.warning .dot { background: var(--warn); }
.issue.info .dot { background: var(--info); }
.issue .body { min-width: 0; }
.issue .msg { font-size: 13px; }
.issue .where { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); margin-top: 2px; word-break: break-all; }
.issue .fix { margin-top: 6px; }

/* ------------------------------- dialogs ---------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 16, 25, 0.42);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.12s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }

.dialog {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: pop-in 0.16s var(--ease);
  overflow: hidden;
}
.dialog.sm { width: min(460px, 100%); }
.dialog.lg { width: min(920px, 100%); }
.dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h3 { font-size: 15.5px; font-weight: 650; }
.dialog-head .sub { font-size: 12px; color: var(--text-faint); }
.dialog-head .close { margin-left: auto; }
.dialog-body { padding: 18px; overflow: auto; }
.dialog-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.dialog-foot .left { margin-right: auto; }

.menu {
  position: fixed;
  z-index: 120;
  min-width: 210px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
  animation: pop-in 0.1s var(--ease);
}
.menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu button svg { width: 14px; height: 14px; color: var(--text-faint); }
.menu button.danger svg { color: var(--danger); }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 5px 3px; }
.menu .menu-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 9px 3px;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 44px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 9px 13px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: pop-in 0.15s var(--ease);
  max-width: 420px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
.toast svg { width: 15px; height: 15px; flex: none; }
.toast.ok svg { color: var(--ok); }
.toast.warn svg { color: var(--warn); }
.toast.error svg { color: var(--danger); }

/* ------------------------------- start ------------------------------ */

.start {
  height: 100%;
  overflow: auto;
  background:
    radial-gradient(1100px 480px at 12% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(900px 420px at 92% 0%, color-mix(in srgb, #8257e5 10%, transparent), transparent 70%),
    var(--bg);
}
.start-inner { max-width: 1080px; margin: 0 auto; padding: 54px 26px 60px; }
.start-hero { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 34px; align-items: center; }
@media (max-width: 900px) { .start-hero { grid-template-columns: 1fr; } }
.start h1 {
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin: 14px 0 10px;
}
.start h1 em { font-style: normal; color: var(--accent); }
.start .lede { font-size: 15.5px; color: var(--text-muted); max-width: 52ch; line-height: 1.6; }
.start-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.start-note { margin-top: 14px; font-size: 12px; color: var(--text-faint); }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  padding: 30px 24px;
  text-align: center;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.15s var(--ease);
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-softer); transform: scale(1.01); }
.dropzone .icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  margin: 0 auto 12px;
}
.dropzone .icon svg { width: 22px; height: 22px; }
.dropzone b { display: block; font-size: 15px; margin-bottom: 4px; }
.dropzone p { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.dropzone .formats { margin-top: 12px; font-size: 11px; color: var(--text-faint); }

.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 34px; }
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.feature .icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  margin-bottom: 10px;
}
.feature .icon svg { width: 16px; height: 16px; }
.feature b { font-size: 13.5px; display: block; margin-bottom: 3px; }
.feature p { font-size: 12.5px; color: var(--text-muted); margin: 0; }

.recent { margin-top: 30px; }
.recent h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 10px; }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}
.recent-item:hover { border-color: var(--accent); }
.recent-item b { font-size: 13px; display: block; }
.recent-item span { font-size: 11px; color: var(--text-faint); }

/* -------------------------------- misc ------------------------------ */

.kbd {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 650;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.banner {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.8px;
  margin-bottom: 16px;
}
.banner .grow { flex: 1 1 240px; min-width: 0; }
.banner svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.banner.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner.info svg { color: var(--info); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.banner.warn svg { color: var(--warn); }
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.banner.ok svg { color: var(--ok); }
.banner .grow { flex: 1; min-width: 0; }
.banner b { display: block; margin-bottom: 2px; }

.inline-list { display: flex; flex-wrap: wrap; gap: 6px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap-lg { gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.search-results { display: flex; flex-direction: column; gap: 2px; }
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}
.search-hit:hover { background: var(--surface-2); border-color: var(--border); }
.search-hit b { font-size: 12.5px; display: block; }
.search-hit .ctx { font-size: 11px; color: var(--text-faint); margin-bottom: 2px; }
.search-hit .snip { font-size: 12px; color: var(--text-muted); }
.search-hit mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ------------------------------- print ------------------------------ */

.print-view { background: #fff; color: #111; padding: 0; height: 100%; overflow: auto; }
#print-root { background: #fff; }
.print-page {
  max-width: 210mm;
  margin: 0 auto;
  padding: 18mm 16mm;
  background: #fff;
  color: #111;
  font-size: 10.5pt;
  line-height: 1.5;
}
.print-page + .print-page { border-top: 1px dashed #ccc; }
.print-page h1 { font-size: 18pt; margin: 0 0 2mm; }
.print-page h2 { font-size: 12pt; margin: 7mm 0 2mm; padding-bottom: 1mm; border-bottom: 0.4pt solid #bbb; }
.print-page h3 { font-size: 10.5pt; margin: 4mm 0 1.5mm; }
.print-page table { width: 100%; border-collapse: collapse; margin: 0 0 3mm; }
.print-page th, .print-page td { text-align: left; vertical-align: top; padding: 1mm 2mm; border-bottom: 0.4pt solid #e2e2e2; }
.print-page th { width: 34%; color: #555; font-weight: 600; }
.print-page .layer-block { border-left: 2pt solid #6d5ce7; padding-left: 3mm; margin: 3mm 0; }
.print-page .muted { color: #666; }
.print-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

@page {
  size: A4;
  margin: 16mm 15mm 18mm;
}

@media print {
  body { overflow: visible; background: #fff; }
  #app, .toasts, .drop-overlay { display: none !important; }
  #print-root { display: block !important; position: static; }
  .print-page { padding: 0; max-width: none; page-break-after: always; }
  .print-page + .print-page { border-top: none; }
  .print-page table { page-break-inside: avoid; }
  .print-page h1 { page-break-after: avoid; }
}

/* ------------------------------- grid ------------------------------- */

.grid-cover { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.grid-cover.single { grid-template-columns: minmax(0, 1fr); }
.grid-half { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-process { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-process.compact { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }

@media (max-width: 1100px) {
  .grid-cover, .grid-half, .grid-process, .grid-process.compact { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------ drag hint --------------------------- */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
body.dragging .drop-overlay { display: grid; }
.drop-overlay .drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 46px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--accent);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  color: var(--accent);
}
.drop-overlay .drop-card b { font-size: 16px; }
.drop-overlay .drop-card span { font-size: 12.5px; color: var(--text-muted); }
.drop-overlay .drop-card svg { width: 26px; height: 26px; margin-bottom: 4px; }

/* ---------------------------- responsive ---------------------------- */

.menu-toggle { display: none !important; }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .workspace { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; margin-left: -4px; }
  .brand { border-right: none; padding-right: 0; }
  .brand-text { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .doc-title { min-width: 0; overflow: hidden; }
  .doc-title .name { max-width: 34vw; font-size: 14px; }
  #btn-validate, #btn-theme { display: none !important; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .btn .label { display: none; }
  .topbar-actions .btn { width: 34px; padding: 0; }
  .topbar-actions .btn .chip { display: none; }
  .segmented button .label { display: none; }
  .segmented button { padding: 0 9px; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: var(--status-h);
    left: 0;
    width: 300px;
    z-index: 40;
    transform: translateX(-102%);
    transition: transform 0.2s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .page { padding: 16px 14px 60px; }
  .page-title { font-size: 21px; }
  .field-grid, .field-grid.two { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .statusbar { font-size: 11px; gap: 8px; }
  .statusbar #status-counts { display: none; }
  .statusbar .chip { font-size: 10.5px; padding: 0 6px; }
  .start h1 { font-size: 30px; }
  .start-hero { gap: 22px; }
  .start-inner { padding: 30px 18px 40px; }
}
/* ------------------------------------------------------------------ */
/* Office and e-mail previews                                          */
/* ------------------------------------------------------------------ */

.office-preview,
.email-preview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: var(--surface-3);
}

.email-preview { display: flex; flex-direction: column; gap: 12px; }

.preview-loading { color: var(--text-muted); font-size: 12.5px; padding: 6px 2px; }

.preview-note {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 12px;
}

.doc-page {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 34px 38px;
  box-shadow: var(--shadow-sm);
}

.doc-heading { margin: 18px 0 8px; font-size: 15px; line-height: 1.35; }
h2.doc-heading { font-size: 20px; }
h3.doc-heading { font-size: 17px; }
h4.doc-heading, h5.doc-heading, h6.doc-heading { font-size: 14px; }

.doc-paragraph {
  margin: 0 0 10px;
  line-height: 1.6;
  font-size: 13.5px;
  white-space: pre-wrap;
}

.doc-list {
  display: flex;
  gap: 8px;
  margin: 0 0 6px 4px;
  font-size: 13.5px;
  line-height: 1.5;
}

.doc-bullet { color: var(--accent); }

.preview-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
  background: var(--surface);
  margin: 12px 0 16px;
}

.preview-table th,
.preview-table td {
  border: 1px solid var(--border);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}

.preview-table th { background: var(--surface-2); font-weight: 600; }

.sheet-preview { display: flex; flex-direction: column; gap: 10px; }
.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.sheet-host {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 62vh;
}

.sheet-table { border-collapse: collapse; font-size: 12px; min-width: 100%; }

.sheet-table th,
.sheet-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  white-space: nowrap;
}

.sheet-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 1;
  font-weight: 600;
}

.sheet-table tbody th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}

.sheet-table td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.sheet-meta { padding: 6px 10px; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); }

.slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.slide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.slide-no { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.slide-title { font-weight: 600; margin: 4px 0 8px; }
.slide-lines { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.5; }

.mail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.mail-row {
  display: flex;
  gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.mail-row:last-child { border-bottom: 0; }
.mail-label { width: 74px; flex: 0 0 74px; color: var(--text-muted); }
.mail-value { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.mail-body {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.mail-attachments { margin-top: 14px; }

@media (max-width: 900px) {
  .doc-page { padding: 22px 20px; }
  .office-preview, .email-preview { padding: 12px; }
  .slide-grid { grid-template-columns: 1fr; }
}


/* Miniature thumbnails for document cards ------------------------------- */
.thumb { width: 100%; height: 100%; display: grid; place-items: center; padding: 9px; }

.t-page, .t-mail {
  width: 92px;
  height: 112px;
  background: #fbfbf8;
  border-radius: 3px;
  box-shadow: 0 2px 7px rgba(0, 0, 0, .3);
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.t-sheet {
  width: 104px;
  height: 86px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 2px 7px rgba(0, 0, 0, .3);
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.t-slide {
  width: 108px;
  height: 72px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 2px 7px rgba(0, 0, 0, .3);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.t-page .t-h { height: 6px; width: 64%; background: #353535; border-radius: 1px; margin-bottom: 3px; }
.t-page .t-line { height: 2px; background: #c9c9c3; border-radius: 1px; }
.t-page .t-line:nth-child(3n) { background: #dcdcd6; }
.t-page .t-empty { font-size: 8px; color: #9a9a92; }

.t-table { margin-top: auto; display: grid; gap: 1px; background: #d6d6ce; padding: 1px; border-radius: 1px; }
.t-table span { height: 4px; background: #fbfbf8; }

.t-sheet .t-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 2px; }
.t-sheet .t-cell { height: 7px; background: #e8efe9; border-radius: 1px; }
.t-sheet .t-row.head .t-cell { background: #bcdcc6; }

.t-slide .t-title { height: 7px; width: 66%; background: #d24726; border-radius: 1px; margin-bottom: 2px; }
.t-slide .t-line { height: 2px; width: 84%; background: #cfcfcf; border-radius: 1px; }
.t-slide .t-line:nth-child(3) { width: 72%; }
.t-slide .t-line:nth-child(4) { width: 78%; }

.t-mail .t-head { height: 3px; width: 58%; background: #cdd9ea; border-radius: 1px; }
.t-mail .t-subject { height: 5px; width: 76%; background: #5b7fb9; border-radius: 1px; margin: 2px 0 3px; }
.t-mail .t-line { height: 2px; width: 86%; background: #d5d5d0; border-radius: 1px; }
.t-mail .t-line:nth-child(6) { width: 70%; }
.t-mail .t-clip {
  margin-top: auto;
  width: 10px;
  height: 4px;
  border-radius: 2px;
  background: #8a8a84;
  transform: rotate(-35deg);
  opacity: .65;
}

.t-accent { height: 3px; width: 30%; border-radius: 1px; margin-bottom: 2px; }
.t-accent.pdf { background: #c0392b; }
.t-accent.text { background: #4a78b8; }
.t-mail .t-dot { margin-top: auto; width: 6px; height: 6px; border-radius: 50%; background: #8a8a84; opacity: .55; }
