/* ============================================================
   DMS/QMS — Grayscale Production Design
   Brez zunanjih odvisnosti. Vse v sivih tonih.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar */
  --sidebar-w:    248px;
  --topbar-h:     58px;

  /* Grayscale palette */
  --gray-50:      #fafafa;
  --gray-100:     #f4f4f5;
  --gray-150:     #ececee;
  --gray-200:     #e4e4e7;
  --gray-300:     #d4d4d8;
  --gray-400:     #a1a1aa;
  --gray-500:     #71717a;
  --gray-600:     #52525b;
  --gray-700:     #3f3f46;
  --gray-800:     #27272a;
  --gray-850:     #1f1f23;
  --gray-900:     #18181b;
  --gray-950:     #09090b;

  /* Semantic tokens */
  --bg:           var(--gray-100);
  --surface:      #ffffff;
  --surface-alt:  var(--gray-50);
  --border:       var(--gray-200);
  --border-strong: var(--gray-300);
  --text:         var(--gray-900);
  --text-muted:   var(--gray-500);
  --text-soft:    var(--gray-600);

  --primary:      var(--gray-900);
  --primary-hover: var(--gray-700);
  --primary-text: #ffffff;

  --accent:       var(--gray-700);
  --accent-light: var(--gray-150);

  /* Status colors — still grayscale but with subtle tone shifts */
  --status-draft:    var(--gray-500);
  --status-review:   var(--gray-600);
  --status-approved: var(--gray-800);
  --status-active:   var(--gray-900);
  --status-rejected: #6b5050;
  --status-archived: var(--gray-400);

  /* Sidebar */
  --sidebar-bg:     var(--gray-950);
  --sidebar-text:   var(--gray-400);
  --sidebar-text-active: #ffffff;
  --sidebar-hover-bg: var(--gray-850);
  --sidebar-border: var(--gray-800);

  /* Radii & shadows */
  --radius-sm:    6px;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow-xs:    0 1px 1px rgba(0,0,0,.04);
  --shadow-sm:    0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.05);
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 4px 8px rgba(0,0,0,.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,.07), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg:    0 12px 24px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--gray-800); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--gray-950); }

::selection { background: var(--gray-300); color: var(--gray-950); }

/* ── Layout ─────────────────────────────────────────────────── */
.dms-wrapper { display: flex; min-height: 100vh; }

.dms-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
}
.dms-sidebar::-webkit-scrollbar { width: 4px; }
.dms-sidebar::-webkit-scrollbar-track { background: transparent; }
.dms-sidebar::-webkit-scrollbar-thumb { background: var(--gray-800); border-radius: 2px; }

.dms-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar Brand ───────────────────────────────────────────── */
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: #ffffff;
  color: var(--gray-900);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  letter-spacing: -.02em;
}
.sidebar-brand-text {
  font-weight: 600; font-size: .9rem;
  color: #ffffff; line-height: 1.2;
  letter-spacing: -.01em;
}
.sidebar-brand-text small {
  display: block; font-size: .68rem;
  color: var(--gray-500); font-weight: 400;
  margin-top: 2px; letter-spacing: .02em;
}

/* ── Sidebar Nav ─────────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-group-label {
  padding: 18px 12px 6px;
  font-size: .68rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--gray-600);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  font-size: .875rem; font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin: 1px 0;
  transition: all .15s ease;
}
.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
}
.nav-item.active {
  background: var(--gray-800);
  color: var(--sidebar-text-active);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; width: 3px; height: 20px;
  background: #ffffff;
  border-radius: 0 2px 2px 0;
  margin-left: -8px;
}
.nav-item { position: relative; }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; opacity: .9; }
.nav-label { flex: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  font-size: .72rem;
  color: var(--gray-600);
  text-align: center;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.dms-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: .95rem; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem;
  color: var(--text-soft);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.topbar-user-avatar {
  width: 30px; height: 30px;
  background: var(--gray-200);
  color: var(--gray-700);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem;
}
.topbar-user-name { font-weight: 500; color: var(--text); }
.topbar-user-role { font-size: .72rem; color: var(--text-muted); }

/* ── Content ─────────────────────────────────────────────────── */
.dms-content { padding: 24px 28px; flex: 1; max-width: 1400px; width: 100%; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.5rem; font-weight: 600;
  color: var(--text); letter-spacing: -.02em;
  display: flex; align-items: center; gap: 10px;
}
.page-header-left { display: flex; align-items: center; gap: 16px; }
.page-subtitle { color: var(--text-muted); font-size: .875rem; margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  gap: 12px;
}
.card-title {
  font-size: .95rem; font-weight: 600;
  color: var(--text); letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: all .2s ease;
}
.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.stat-label {
  font-size: .72rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.85rem; font-weight: 600;
  color: var(--text); letter-spacing: -.03em;
  line-height: 1;
}
.stat-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: .85rem; font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:focus-visible { outline: 2px solid var(--gray-400); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--gray-900);
  color: #ffffff;
  border-color: var(--gray-900);
}
.btn-primary:hover:not(:disabled) {
  background: var(--gray-700);
  border-color: var(--gray-700);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--text);
}

.btn-danger {
  background: var(--surface);
  color: var(--status-rejected);
  border-color: var(--border-strong);
}
.btn-danger:hover:not(:disabled) {
  background: #f5e8e8;
  border-color: var(--status-rejected);
}

.btn-success { /* still grayscale-ish */
  background: var(--gray-800);
  color: #ffffff;
  border-color: var(--gray-800);
}
.btn-success:hover:not(:disabled) {
  background: var(--gray-900);
}

.btn-warning {
  background: var(--surface);
  color: var(--gray-800);
  border-color: var(--border-strong);
}

.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 11px 20px; font-size: .92rem; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.form-label {
  display: block;
  font-size: .82rem; font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: .88rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: all .15s ease;
}
.form-control:hover { border-color: var(--gray-400); }
.form-control:focus {
  outline: none;
  border-color: var(--gray-700);
  box-shadow: 0 0 0 3px rgba(63,63,70,.1);
}
.form-control:disabled { background: var(--gray-100); color: var(--text-muted); cursor: not-allowed; }

textarea.form-control { min-height: 80px; resize: vertical; font-family: inherit; line-height: 1.55; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2371717a' d='M6 8.5L1.5 4h9z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-actions {
  display: flex; gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.form-actions.no-border { border-top: none; padding-top: 0; }

.req { color: var(--status-rejected); }

/* Checkbox / Radio */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--gray-800);
  width: 16px; height: 16px;
  cursor: pointer;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.filter-bar .form-control { width: auto; min-width: 180px; }

/* ── Tables ──────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}
.data-table th {
  text-align: left;
  padding: 11px 16px;
  font-weight: 600;
  font-size: .72rem; letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-150);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table .actions { white-space: nowrap; text-align: right; }
.data-table code, .data-table .font-mono { font-family: var(--font-mono); font-size: .85em; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  font-size: .72rem; font-weight: 500;
  border-radius: 100px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-success     { background: var(--gray-800); color: #fff; }
.badge-warning     { background: var(--gray-200); color: var(--gray-800); }
.badge-danger      { background: #f5e8e8; color: var(--status-rejected); }
.badge-info        { background: var(--gray-150); color: var(--gray-700); }
.badge-secondary   { background: var(--gray-150); color: var(--gray-600); }
.badge-primary     { background: var(--gray-900); color: #fff; }

/* Status badges with dot indicator */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  font-size: .75rem; font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  color: var(--text-soft);
}
.status-badge::before {
  content: ''; width: 6px; height: 6px;
  background: var(--gray-400); border-radius: 50%;
}
.status-draft::before    { background: var(--gray-400); }
.status-in_review::before { background: var(--gray-500); animation: pulse 2s infinite; }
.status-approved_tech::before, .status-approved_tpm::before, .status-approved::before { background: var(--gray-700); }
.status-active::before   { background: var(--gray-900); }
.status-needs_revision::before, .status-rejected::before { background: var(--status-rejected); }
.status-archived::before { background: var(--gray-300); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 16px;
  font-size: .87rem;
  display: flex; gap: 10px; align-items: flex-start;
  line-height: 1.5;
}
.alert-info    { background: var(--gray-50); border-color: var(--border); color: var(--text); }
.alert-success { background: var(--gray-50); border-color: var(--gray-300); color: var(--text); }
.alert-warning { background: #fdfaf3; border-color: #e8dcc4; color: var(--gray-800); }
.alert-danger  { background: #fbf3f3; border-color: #e8c4c4; color: var(--status-rejected); }

/* ── Approval Flow Visualization ─────────────────────────────── */
.approval-flow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0; padding: 8px 0;
}
.approval-step {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; position: relative;
}
.approval-step:not(:last-child)::after {
  content: '';
  position: absolute; top: 18px; left: 60%; width: 80%;
  height: 2px; background: var(--gray-200);
  z-index: 0;
}
.approval-step.done:not(:last-child)::after { background: var(--gray-700); }
.approval-circle {
  width: 36px; height: 36px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
  color: var(--text-muted);
  z-index: 1; position: relative;
  margin-bottom: 8px;
}
.approval-step.done .approval-circle {
  background: var(--gray-900); color: #fff;
  border-color: var(--gray-900);
}
.approval-step.pending .approval-circle {
  background: var(--surface);
  border-color: var(--gray-400);
  border-style: dashed;
}
.approval-step.rejected .approval-circle {
  background: var(--status-rejected); color: #fff;
  border-color: var(--status-rejected);
}
.approval-step-label {
  font-size: .8rem; font-weight: 500;
  color: var(--text);
}
.approval-step-meta {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: 20px;
}
.tab {
  padding: 11px 18px;
  border: none; background: none;
  font-size: .87rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s ease;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gray-900); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Document Meta ───────────────────────────────────────────── */
.doc-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
}
.doc-meta-item { min-width: 0; }
.doc-meta-label {
  font-size: .7rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.doc-meta-value {
  font-size: .9rem; font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

/* ── Flash Messages ──────────────────────────────────────────── */
.flash-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 1000; max-width: 380px;
}
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  margin-bottom: 8px;
  font-size: .87rem;
  display: flex; gap: 10px; align-items: flex-start;
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.flash-success { border-left: 3px solid var(--gray-800); }
.flash-error   { border-left: 3px solid var(--status-rejected); }
.flash-warning { border-left: 3px solid var(--gray-500); }
.flash-info    { border-left: 3px solid var(--gray-600); }
.flash-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 0; margin-left: auto;
  font-size: 1.1rem; line-height: 1;
}
.flash-close:hover { color: var(--text); }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex; gap: 4px; list-style: none;
  padding: 14px 20px;
  justify-content: center;
}
.pagination .page-link {
  display: inline-flex; align-items: center;
  padding: 6px 11px;
  font-size: .82rem;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all .15s ease;
}
.pagination .page-link:hover { background: var(--gray-100); color: var(--text); }
.pagination .page-item.active .page-link {
  background: var(--gray-900); color: #fff;
  border-color: var(--gray-900);
}

/* ── Login Page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--gray-100);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,.02) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,.03) 0%, transparent 40%);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: var(--gray-900);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; font-weight: 700;
  letter-spacing: -.02em;
}
.login-brand h1 {
  font-size: 1.4rem; font-weight: 600;
  color: var(--text); letter-spacing: -.02em;
  margin-bottom: 4px;
}
.login-brand p {
  font-size: .85rem; color: var(--text-muted);
}

/* ── Utilities ───────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: .8rem; }
.text-xs       { font-size: .72rem; }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-danger   { color: var(--status-rejected); }
.text-success  { color: var(--gray-800); }
.font-mono     { font-family: var(--font-mono); }
.font-bold     { font-weight: 600; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Empty States ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 2.5rem;
  opacity: .4;
  margin-bottom: 14px;
}
.empty-state-title {
  font-size: .95rem; font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.empty-state-text {
  font-size: .82rem;
  color: var(--text-muted);
}

/* ── WYSIWYG (TinyMCE) Customization ─────────────────────────── */
.tox.tox-tinymce {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border-strong) !important;
}
.tox .tox-toolbar, .tox .tox-toolbar__overflow, .tox .tox-toolbar__primary {
  background: var(--gray-50) !important;
  border-bottom: 1px solid var(--border) !important;
}
.tox .tox-tbtn { color: var(--text) !important; }
.tox .tox-tbtn:hover { background: var(--gray-200) !important; }

/* ── File Upload Zone ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  background: var(--surface-alt);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--gray-700);
  background: var(--gray-50);
}
.upload-zone-icon { font-size: 2rem; opacity: .5; margin-bottom: 8px; }
.upload-zone-text { font-size: .88rem; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.upload-zone-hint { font-size: .78rem; color: var(--text-muted); }

/* ── Attachment List ─────────────────────────────────────────── */
.attachment-list { list-style: none; }
.attachment-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.attachment-icon {
  width: 36px; height: 36px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.attachment-name { font-size: .87rem; font-weight: 500; color: var(--text); }
.attachment-meta { font-size: .75rem; color: var(--text-muted); }

/* ── Content Display (Document Body) ─────────────────────────── */
.content-display {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  line-height: 1.65;
  color: var(--text);
}
.content-display h1, .content-display h2, .content-display h3 {
  margin: 18px 0 10px; font-weight: 600; letter-spacing: -.01em;
}
.content-display h1 { font-size: 1.3rem; }
.content-display h2 { font-size: 1.15rem; }
.content-display h3 { font-size: 1.02rem; }
.content-display p { margin-bottom: 12px; }
.content-display ul, .content-display ol { margin: 10px 0 12px 28px; }
.content-display li { margin-bottom: 4px; }
.content-display img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 10px 0; }
.content-display table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
}
.content-display table th, .content-display table td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.content-display table th { background: var(--gray-100); font-weight: 600; }
.content-display blockquote {
  border-left: 3px solid var(--gray-300);
  padding-left: 14px; margin: 12px 0;
  color: var(--text-soft); font-style: italic;
}
.content-display code {
  background: var(--gray-100); padding: 1px 6px;
  border-radius: 4px; font-family: var(--font-mono);
  font-size: .85em;
}
.content-display pre {
  background: var(--gray-900); color: var(--gray-100);
  padding: 12px 14px; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 12px 0;
  font-family: var(--font-mono); font-size: .82rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dms-sidebar { transform: translateX(-100%); }
  .dms-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .dms-main { margin-left: 0; }
  .dms-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .dms-sidebar, .dms-topbar, .no-print, .btn, .filter-bar, .pagination, .flash-container, .form-actions { display: none !important; }
  .dms-main { margin-left: 0; }
  .dms-content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
  .doc-meta { background: #f9f9f9; }
}

/* ── Legacy class aliases (Codex compat) ─────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: .87rem; }
.tbl th { text-align: left; padding: 11px 16px; font-weight: 600; font-size: .72rem;
          letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
          background: var(--surface-alt); border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--gray-150); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--gray-50); }
.tbl-actions, .tbl .actions { white-space: nowrap; text-align: right; }
.table-wrap { overflow-x: auto; }
.bg-primary { background: var(--gray-900); color: #fff; }
.bg-success { background: var(--gray-800); color: #fff; }
.bg-secondary { background: var(--gray-150); color: var(--gray-700); }
.bg-info { background: var(--gray-150); color: var(--gray-700); }
.bg-warning { background: var(--gray-200); color: var(--gray-800); }
.bg-danger { background: #f5e8e8; color: var(--status-rejected); }
.bg-dark { background: var(--gray-700); color: #fff; }

/* ── KPI Cards (dashboard) ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 2px;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
  align-items: center;
}
.kpi-card > .kpi-icon  { grid-row: 1 / span 2; grid-column: 1; align-self: center; }
.kpi-card > .kpi-value { grid-row: 1; grid-column: 2; }
.kpi-card > .kpi-label { grid-row: 2; grid-column: 2; }
.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gray-400);
}
.kpi-card.kpi-slate::before  { background: var(--gray-400); }
.kpi-card.kpi-green::before  { background: var(--gray-800); }
.kpi-card.kpi-amber::before  { background: var(--gray-500); }
.kpi-card.kpi-red::before    { background: var(--status-rejected); }
.kpi-card.kpi-blue::before   { background: var(--gray-600); }
.kpi-card.kpi-purple::before { background: var(--gray-700); }

.kpi-icon {
  width: 38px; height: 38px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.kpi-card.kpi-green  .kpi-icon { background: var(--gray-150); color: var(--gray-900); }
.kpi-card.kpi-red    .kpi-icon { background: #f5e8e8; color: var(--status-rejected); }

.kpi-content { flex: 1; min-width: 0; }
.kpi-value {
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1.05;
  margin-bottom: 2px;
}
.kpi-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .02em;
}

/* When kpi-icon comes BEFORE value (current dashboard layout) */
.kpi-card > .kpi-icon + .kpi-value,
.kpi-card > .kpi-icon ~ .kpi-value { font-size: 1.85rem; }

/* ── Misc helper classes ─────────────────────────────────────── */
.btn-outline {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--text);
  border-color: var(--gray-400);
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive dashboard grid (2-col → 1-col on mobile) */
@media (max-width: 880px) {
  .dms-content > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Language Switch (pill) ──────────────────────────────────── */
.lang-switch {
  display: inline-flex;
  background: var(--gray-100);
  border-radius: 100px;
  padding: 2px;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .02em;
}
.lang-switch a {
  display: inline-block;
  padding: 4px 8px;
  color: var(--text-muted);
  border-radius: 100px;
  text-decoration: none;
  transition: all .15s ease;
  line-height: 1.4;
}
.lang-switch a:hover { color: var(--text); }
.lang-switch a.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ── Additional legacy aliases (Codex) ───────────────────────── */
.filters-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  align-items: end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label {
  font-size: .72rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted);
}

.approval-arrow { color: var(--gray-400); padding: 0 4px; font-weight: 600; }
.approval-step-date { font-size: .7rem; color: var(--text-muted); }
.approval-step-icon { font-size: 1rem; }
.approval-step-name { font-size: .82rem; font-weight: 500; color: var(--text); }
.approval-step-role { font-size: .72rem; color: var(--text-muted); }

.approval-table, .ack-table, .meta-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.approval-table th, .ack-table th, .meta-table th {
  text-align: left; padding: 10px 14px;
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  font-weight: 600; color: var(--text-muted);
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
}
.approval-table td, .ack-table td, .meta-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-150);
}
.meta-table tr:last-child td { border-bottom: none; }

.ack-box {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  margin-bottom: 14px;
}
.ack-card-input {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: .1em;
  text-align: center;
  padding: 12px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  width: 100%;
  cursor: text;
}
.ack-card-input:focus { border-color: var(--gray-700); outline: none; }
.ack-scanner-btn {
  margin-top: 8px;
  padding: 10px 18px;
  background: var(--gray-900); color: #fff;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 500;
}

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; color: var(--text-muted);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--text-soft); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--gray-300); }

.doc-id {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 4px;
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
}

.content-box {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.6;
  min-height: 120px;
}
.content-box h1, .content-box h2, .content-box h3 { margin: 14px 0 8px; font-weight: 600; }
.content-box h1 { font-size: 1.25rem; } .content-box h2 { font-size: 1.1rem; } .content-box h3 { font-size: 1rem; }
.content-box p { margin-bottom: 10px; }
.content-box ul, .content-box ol { margin: 8px 0 10px 24px; }
.content-box img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 8px 0; }
.content-box table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.content-box table th, .content-box table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.content-box table th { background: var(--gray-100); font-weight: 600; }
.content-box blockquote { border-left: 3px solid var(--gray-300); padding-left: 14px; color: var(--text-soft); }

.qr-box {
  display: inline-block;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.qr-label { font-size: .78rem; color: var(--text-muted); margin-top: 8px; }
.qr-box img { max-width: 200px; }

.section-title {
  font-size: .92rem; font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
  margin: 18px 0 10px;
}
.print-header {
  border-bottom: 2px solid var(--gray-800);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.footer { text-align: center; padding: 16px; color: var(--text-muted); font-size: .8rem; }
.ml-1 { margin-left: 8px; }
.fw-bold { font-weight: 600; }
.text-warning { color: var(--gray-700); }

/* ── Bootstrap-style .table fallback (Codex compat) ──────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
  margin-bottom: 0;
}
.table > thead > tr > th {
  text-align: left;
  padding: 11px 16px;
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table > tbody > tr > td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-150);
  vertical-align: middle;
}
.table > tbody > tr:last-child > td { border-bottom: none; }
.table > tbody > tr:hover { background: var(--gray-50); }
.table .actions, .table td.actions {
  white-space: nowrap; text-align: right;
}

/* Make sure tables inside .card don't overflow card padding */
.card > .table, .card > .table-wrap > .table {
  margin: 0;
}
.card > .table:first-child > thead > tr > th:first-child,
.card > .table > thead > tr > th:first-child { padding-left: 20px; }
.card > .table > tbody > tr > td:first-child { padding-left: 20px; }
.card > .table > thead > tr > th:last-child,
.card > .table > tbody > tr > td:last-child { padding-right: 20px; }
