/* ==========================================================================
   Contracts 365 — Design System
   SeerDynamics Contract Lifecycle Management Portal
   Plain, hand-written CSS. No frameworks, no CDN dependencies.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  --blue-50:  #eef4ff;
  --blue-100: #dce8ff;
  --blue-200: #b3cdff;
  --blue-300: #85adff;
  --blue-400: #5589f5;
  --blue-500: #2f6fed;
  --blue-600: #2158d1;
  --blue-700: #1a45a8;
  --blue-800: #163a87;
  --blue-900: #122d68;

  --grey-25:  #fafbfc;
  --grey-50:  #f5f7fa;
  --grey-100: #eef1f5;
  --grey-200: #e2e6ec;
  --grey-300: #cfd5de;
  --grey-400: #a8b0bd;
  --grey-500: #7c8598;
  --grey-600: #5a6475;
  --grey-700: #414a5a;
  --grey-800: #2b3242;
  --grey-900: #171c26;

  --emerald-50: #e8f9f2;
  --emerald-500: #0f9d78;
  --emerald-600: #0c8563;

  --orange-50: #fff4e8;
  --orange-500: #e2622a;
  --orange-600: #c9501f;

  --red-50: #fdecea;
  --red-500: #d64545;
  --red-600: #b93636;

  --lightblue-50: #eef8ff;
  --lightblue-500: #3aa0e0;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(23, 28, 38, 0.06);
  --shadow-sm: 0 2px 8px rgba(23, 28, 38, 0.06), 0 1px 2px rgba(23,28,38,0.04);
  --shadow-md: 0 8px 24px rgba(23, 28, 38, 0.08), 0 2px 6px rgba(23,28,38,0.04);
  --shadow-lg: 0 16px 48px rgba(23, 28, 38, 0.14), 0 4px 12px rgba(23,28,38,0.06);
  --shadow-focus: 0 0 0 3px rgba(47, 111, 237, 0.18);

  --font-sans: 'Segoe UI Variable Display', 'Segoe UI Variable', 'Segoe UI Semibold', 'Segoe UI Historic', 'Segoe UI', system-ui, sans-serif;

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 68px;

  --transition-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);

  /* semantic (light theme defaults) */
  --bg-app: var(--grey-50);
  --bg-surface: #ffffff;
  --bg-surface-alt: var(--grey-25);
  --bg-sunken: var(--grey-100);
  --text-primary: var(--grey-900);
  --text-secondary: var(--grey-600);
  --text-tertiary: var(--grey-500);
  --border-subtle: var(--grey-200);
  --border-strong: var(--grey-300);
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255,255,255,0.86);
}

[data-theme="dark"] {
  --bg-app: #10131a;
  --bg-surface: #171c26;
  --bg-surface-alt: #1d2330;
  --bg-sunken: #1a1f2b;
  --text-primary: #eef1f5;
  --text-secondary: #a8b0bd;
  --text-tertiary: #7c8598;
  --border-subtle: #262d3b;
  --border-strong: #323a4a;
  --sidebar-bg: #12151d;
  --topbar-bg: rgba(16, 19, 26, 0.86);
  --blue-50: #152142;
  --emerald-50: #10261f;
  --orange-50: #2b1d10;
  --red-50: #2c1414;
  --lightblue-50: #10202c;
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-base), color var(--transition-base);
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--blue-200); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. Icons (Lucide-style inline SVG via helper) ---------- */
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

/* ---------- 4. App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width var(--transition-base);
  z-index: 40;
}
.app-shell.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px 16px;
  white-space: nowrap; overflow: hidden;
}
.sidebar-brand .brand-mark {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 15.5px; color: var(--text-primary); }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--text-tertiary); font-weight: 500; letter-spacing: 0.02em; }
.app-shell.sidebar-collapsed .brand-text { display: none; }

.sidebar-collapse-btn {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin-left: auto; transition: all var(--transition-fast);
}
.sidebar-collapse-btn:hover { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-200); }

.sidebar-search {
  margin: 4px 16px 12px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 8px 12px; color: var(--text-tertiary);
  font-size: 13px; cursor: pointer; transition: border-color var(--transition-fast);
}
.sidebar-search:hover { border-color: var(--border-strong); }
.sidebar-search kbd {
  margin-left: auto; font-size: 11px; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: 5px; padding: 1px 6px; color: var(--text-tertiary);
}
.app-shell.sidebar-collapsed .sidebar-search span, .app-shell.sidebar-collapsed .sidebar-search kbd { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav-group { margin-bottom: 6px; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); padding: 14px 10px 6px;
}
.app-shell.sidebar-collapsed .nav-group-label { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13.6px; font-weight: 500;
  margin-bottom: 2px; position: relative; transition: all var(--transition-fast);
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg-sunken); color: var(--text-primary); }
.nav-item.active { background: var(--blue-50); color: var(--blue-600); font-weight: 600; }
.nav-item.active .icon { color: var(--blue-600); }
.nav-item .icon { color: var(--text-tertiary); }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 4px; background: var(--blue-500);
}
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; }
.app-shell.sidebar-collapsed .nav-item .nav-label { display: none; }
.app-shell.sidebar-collapsed .nav-item.active::before { left: -12px; }

.sidebar-footer { padding: 10px 12px 18px; border-top: 1px solid var(--border-subtle); }

/* ---------- 5. Main column / topbar ---------- */
.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; position: sticky; top: 0; z-index: 30;
  background: var(--topbar-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-tertiary); }
.breadcrumb .crumb-current { color: var(--text-primary); font-weight: 600; }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--text-tertiary); }

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

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition-fast); position: relative;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn .badge-dot {
  position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--red-500); border: 2px solid var(--bg-surface);
}

.user-menu-trigger { display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border-radius: var(--radius-pill); cursor: pointer; transition: background var(--transition-fast); border: 1px solid transparent; }
.user-menu-trigger:hover { background: var(--bg-sunken); border-color: var(--border-subtle); }
.user-name-block { display: flex; flex-direction: column; line-height: 1.2; }
.user-name-block .u-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-name-block .u-role { font-size: 11px; color: var(--text-tertiary); }

.page-content { flex: 1; padding: 26px 28px 48px; max-width: 1600px; width: 100%; margin: 0 auto; }

@media (max-width: 1080px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-shell.mobile-nav-open .sidebar { transform: translateX(0); }
  .page-content { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
}

/* ---------- 6. Avatar ---------- */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; flex-shrink: 0; letter-spacing: 0.02em;
}
.avatar-28 { width: 28px; height: 28px; font-size: 11px; }
.avatar-36 { width: 36px; height: 36px; font-size: 12.5px; }
.avatar-44 { width: 44px; height: 44px; font-size: 14px; }
.avatar-64 { width: 64px; height: 64px; font-size: 20px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--bg-surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13.6px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all var(--transition-fast);
  white-space: nowrap; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue-500); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--blue-600); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-sunken); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text-primary); }
.btn-danger { background: var(--red-500); color: #fff; }
.btn-danger:hover { background: var(--red-600); }
.btn-success { background: var(--emerald-500); color: #fff; }
.btn-success:hover { background: var(--emerald-600); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon-only { padding: 9px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 8. Cards & surfaces ---------- */
.card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.card-pad { padding: 22px 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-header .card-header-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.card-body { padding: 16px 24px 22px; }
.card-divider { border-top: 1px solid var(--border-subtle); }

.section-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.section-sub { color: var(--text-secondary); font-size: 13.5px; margin-top: 4px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 9. KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
@media (max-width: 1240px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.kpi-icon.tone-blue { background: linear-gradient(135deg, var(--blue-400), var(--blue-600)); }
.kpi-icon.tone-emerald { background: linear-gradient(135deg, #21c299, var(--emerald-600)); }
.kpi-icon.tone-orange { background: linear-gradient(135deg, #f2924f, var(--orange-600)); }
.kpi-icon.tone-red { background: linear-gradient(135deg, #e26565, var(--red-600)); }
.kpi-info-btn { color: var(--text-tertiary); cursor: pointer; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: var(--radius-pill); width: fit-content; }
.kpi-trend.up { color: var(--emerald-600); background: var(--emerald-50); }
.kpi-trend.down { color: var(--red-600); background: var(--red-50); }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; }

/* ---------- 10. Badges / pills / tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.neutral { background: var(--grey-100); color: var(--grey-600); }
.badge.success { background: var(--emerald-50); color: var(--emerald-600); }
.badge.warning { background: var(--orange-50); color: var(--orange-600); }
.badge.danger  { background: var(--red-50); color: var(--red-600); }
.badge.info    { background: var(--lightblue-50); color: var(--blue-600); }

.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 6px; background: var(--bg-sunken); color: var(--text-secondary); font-size: 11.5px; font-weight: 600; border: 1px solid var(--border-subtle); }

/* ---------- 11. Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.4px; }
.data-table thead th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary); padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt); position: sticky; top: 0; white-space: nowrap;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--text-primary); }
.data-table thead th .sort-caret { display: inline-block; margin-left: 4px; opacity: 0.5; }
.data-table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .cell-primary { font-weight: 600; color: var(--text-primary); }
.data-table .cell-muted { color: var(--text-tertiary); }
.row-checkbox, .head-checkbox { width: 16px; height: 16px; accent-color: var(--blue-500); cursor: pointer; }

.context-menu-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text-tertiary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.context-menu-btn:hover { background: var(--bg-sunken); border-color: var(--border-subtle); color: var(--text-primary); }

/* ---------- 12. Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-input {
  display: flex; align-items: center; gap: 8px; background: var(--bg-surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 9px 14px;
  min-width: 260px; color: var(--text-tertiary); transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-input:focus-within { border-color: var(--blue-400); box-shadow: var(--shadow-focus); }
.search-input input { border: none; outline: none; background: transparent; width: 100%; color: var(--text-primary); font-size: 13.5px; }
.search-input input::placeholder { color: var(--text-tertiary); }

.select-field, .text-field, .textarea-field {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px;
  background: var(--bg-surface); color: var(--text-primary); font-size: 13.5px; outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast); width: 100%;
}
.select-field:focus, .text-field:focus, .textarea-field:focus { border-color: var(--blue-400); box-shadow: var(--shadow-focus); }
.textarea-field { resize: vertical; min-height: 90px; }

.view-toggle { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { padding: 8px 12px; background: var(--bg-surface); color: var(--text-tertiary); border: none; cursor: pointer; display: flex; align-items: center; }
.view-toggle button.active { background: var(--blue-50); color: var(--blue-600); }
.view-toggle button + button { border-left: 1px solid var(--border-strong); }

.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill);
  background: var(--blue-50); color: var(--blue-600); font-size: 12.5px; font-weight: 600; border: 1px solid var(--blue-100);
}
.filter-chip button { background: none; border: none; color: inherit; cursor: pointer; display: flex; }

/* ---------- 13. Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 20px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.col-span-2 { grid-column: span 2; }
@media (max-width: 760px) { .form-field.col-span-2 { grid-column: span 1; } }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.form-label .required { color: var(--red-500); margin-left: 2px; }
.form-hint { font-size: 11.5px; color: var(--text-tertiary); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--blue-500); }

/* ---------- 14. Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 11px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-tertiary);
  border: none; background: none; cursor: pointer; position: relative; white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--blue-600); }
.tab-btn.active::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--blue-500); border-radius: 2px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 15. Timeline ---------- */
.timeline { position: relative; padding-left: 6px; }
.timeline-item { position: relative; padding: 0 0 22px 30px; }
.timeline-item::before {
  content: ''; position: absolute; left: 5px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue-500); box-shadow: 0 0 0 4px var(--blue-50);
}
.timeline-item::after {
  content: ''; position: absolute; left: 9px; top: 16px; bottom: -4px; width: 2px; background: var(--border-subtle);
}
.timeline-item:last-child::after { display: none; }
.timeline-item.tone-success::before { background: var(--emerald-500); box-shadow: 0 0 0 4px var(--emerald-50); }
.timeline-item.tone-warning::before { background: var(--orange-500); box-shadow: 0 0 0 4px var(--orange-50); }
.timeline-item.tone-danger::before  { background: var(--red-500); box-shadow: 0 0 0 4px var(--red-50); }
.timeline-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.timeline-date { font-size: 11.5px; color: var(--text-tertiary); font-weight: 500; }
.timeline-body { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- 16. Wizard ---------- */
.wizard-steps { display: flex; align-items: center; margin-bottom: 28px; overflow-x: auto; padding-bottom: 4px; }
.wizard-step { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.wizard-step-circle {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  color: var(--text-tertiary); background: var(--bg-surface); flex-shrink: 0; transition: all var(--transition-fast);
}
.wizard-step.done .wizard-step-circle { background: var(--emerald-500); border-color: var(--emerald-500); color: #fff; }
.wizard-step.current .wizard-step-circle { background: var(--blue-500); border-color: var(--blue-500); color: #fff; box-shadow: 0 0 0 4px var(--blue-50); }
.wizard-step-label { font-size: 12.5px; font-weight: 600; color: var(--text-tertiary); white-space: nowrap; }
.wizard-step.current .wizard-step-label, .wizard-step.done .wizard-step-label { color: var(--text-primary); }
.wizard-connector { width: 40px; height: 2px; background: var(--border-strong); margin: 0 8px; flex-shrink: 0; }
.wizard-step.done + .wizard-connector { background: var(--emerald-500); }
.wizard-panel { display: none; }
.wizard-panel.active { display: block; animation: fadeSlideIn var(--transition-base); }
.wizard-actions { display: flex; justify-content: space-between; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border-subtle); }

@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------- 17. Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17, 21, 29, 0.5); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 200; animation: fadeIn var(--transition-base);
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg-surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: scaleIn var(--transition-base); max-height: 88vh; display: flex; flex-direction: column; }
.modal-box.modal-lg { max-width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-subtle); }
.modal-header h3 { font-size: 16px; }
.modal-close { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--bg-sunken); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 18. Dropdowns (notifications, user menu) ---------- */
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); right: 0; width: 340px; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: none; z-index: 100; animation: scaleIn var(--transition-fast); overflow: hidden;
}
.dropdown-panel.open { display: block; }
.dropdown-header { padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; }
.dropdown-header h4 { font-size: 13.5px; }
.dropdown-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background var(--transition-fast); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-surface-alt); }
.notif-item.unread { background: var(--blue-50); }
.notif-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.notif-icon.tone-info { background: var(--blue-500); }
.notif-icon.tone-success { background: var(--emerald-500); }
.notif-icon.tone-warning { background: var(--orange-500); }
.notif-icon.tone-danger { background: var(--red-500); }
.notif-text { font-size: 12.8px; color: var(--text-primary); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }
.dropdown-footer { padding: 10px 18px; text-align: center; border-top: 1px solid var(--border-subtle); }

.user-menu-panel { padding: 8px; }
.user-menu-panel .um-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; }
.user-menu-panel .um-item:hover { background: var(--bg-sunken); color: var(--text-primary); }
.user-menu-panel .um-divider { height: 1px; background: var(--border-subtle); margin: 6px 4px; }

/* ---------- 19. Empty / loading states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 64px 24px; color: var(--text-secondary); }
.empty-state .empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--bg-sunken); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; color: var(--text-tertiary); }
.empty-state h4 { font-size: 15.5px; color: var(--text-primary); margin-bottom: 6px; }
.empty-state p { font-size: 13.3px; max-width: 340px; }

.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border-subtle) 37%, var(--bg-sunken) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: 6px; }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 20. Chart containers ---------- */
.chart-legend { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.legend-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.legend-dot::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--legend-color, var(--blue-500)); }
.chart-tooltip { position: absolute; pointer-events: none; background: var(--grey-900); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow-md); opacity: 0; transition: opacity var(--transition-fast); z-index: 20; white-space: nowrap; }
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-title { font-weight: 700; margin-bottom: 3px; }
.chart-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: #dfe3ea; }

/* ---------- 21. Progress / meters ---------- */
.progress-track { height: 8px; border-radius: var(--radius-pill); background: var(--bg-sunken); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--blue-400), var(--blue-600)); transition: width 600ms ease; }
.progress-fill.tone-emerald { background: linear-gradient(90deg, #21c299, var(--emerald-600)); }
.progress-fill.tone-orange { background: linear-gradient(90deg, #f2924f, var(--orange-600)); }
.progress-fill.tone-red { background: linear-gradient(90deg, #e26565, var(--red-600)); }

/* ---------- 22. Pagination ---------- */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; gap: 10px; }
.pagination-info { font-size: 12.8px; color: var(--text-tertiary); }
.pagination-controls { display: flex; align-items: center; gap: 4px; }
.page-btn { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text-secondary); font-size: 12.8px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.page-btn:hover { background: var(--bg-sunken); }
.page-btn.active { background: var(--blue-500); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 23. Utilities ---------- */
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-secondary { color: var(--text-secondary); } .text-tertiary { color: var(--text-tertiary); }
.text-sm { font-size: 12.5px; } .text-xs { font-size: 11.3px; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.w-full { width: 100%; } .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.divider-h { height: 1px; background: var(--border-subtle); border: none; margin: 18px 0; }
.card-list-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border-subtle); }
.card-list-row:last-child { border-bottom: none; }

/* ---------- 24. Contract cards (card view) ---------- */
.contract-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; cursor: pointer; }
.contract-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.contract-card-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--blue-600); background: var(--blue-50); padding: 3px 9px; border-radius: var(--radius-pill); }
.contract-card-title { font-size: 14.5px; font-weight: 700; line-height: 1.35; }
.contract-card-party { font-size: 12.5px; color: var(--text-secondary); }
.contract-card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-tertiary); }
.contract-card-value { font-size: 16px; font-weight: 700; }
.contract-card-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.contract-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1240px) { .contract-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .contract-grid { grid-template-columns: 1fr; } }

/* ---------- 25. Login page ---------- */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .login-shell { grid-template-columns: 1fr; } }
.login-visual { background: linear-gradient(160deg, var(--blue-700), var(--blue-900)); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-visual::after { content: ''; position: absolute; width: 480px; height: 480px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,0.08), transparent 70%); top: -140px; right: -140px; }
@media (max-width: 900px) { .login-visual { display: none; } }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--bg-app); }
.login-card { width: 100%; max-width: 400px; }
.login-quick-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.login-quick-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition-fast); }
.login-quick-item:hover { border-color: var(--blue-300); background: var(--blue-50); }
.login-stat { display: flex; flex-direction: column; }
.login-stat .num { font-size: 26px; font-weight: 700; }
.login-stat .lbl { font-size: 12px; opacity: 0.75; }

/* ---------- 26. Theme toggle switch ---------- */
.theme-toggle { width: 46px; height: 26px; border-radius: 999px; background: var(--bg-sunken); border: 1px solid var(--border-subtle); position: relative; cursor: pointer; flex-shrink: 0; }
.theme-toggle .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg-surface); box-shadow: var(--shadow-xs); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); transition: transform var(--transition-base); }
[data-theme="dark"] .theme-toggle .knob { transform: translateX(20px); background: var(--blue-500); color: #fff; }

/* ---------- 27. Print / misc ---------- */
.confidential-stamp { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; color: var(--red-600); background: var(--red-50); padding: 3px 9px; border-radius: 5px; }
.doc-thumb { width: 42px; height: 52px; border-radius: 6px; background: var(--bg-sunken); border: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); flex-shrink: 0; }
.upload-dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 40px 20px; text-align: center; color: var(--text-secondary); transition: all var(--transition-fast); cursor: pointer; }
.upload-dropzone.dragover { border-color: var(--blue-400); background: var(--blue-50); }
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-left: 4px solid var(--emerald-500); box-shadow: var(--shadow-md); border-radius: var(--radius-sm); padding: 12px 16px; min-width: 280px; display: flex; align-items: center; gap: 10px; animation: scaleIn var(--transition-base); }
.toast.tone-danger { border-left-color: var(--red-500); }
.toast.tone-warning { border-left-color: var(--orange-500); }

/* ---------- 28. Brand logo treatments ---------- */
.brand-logo-full { height: 26px; width: auto; display: block; }
.brand-logo-mark { height: 34px; width: auto; display: block; }
.app-shell.sidebar-collapsed .brand-logo-full { display: none; }
.app-shell.sidebar-collapsed .brand-logo-mark-collapsed { display: block; margin: 0 auto; }
.app-shell.sidebar-collapsed .sidebar-brand { padding: 20px 10px 16px; flex-wrap: wrap; justify-content: center; gap: 8px; }
.brand-logo-mark-collapsed { display: none; width: 34px; height: 34px; object-fit: contain; }
[data-theme="dark"] .brand-logo-full { filter: brightness(0) invert(1); }
.login-brand-mark { height: 30px; width: auto; }
.login-form-logo { height: 34px; width: auto; margin-bottom: 22px; }
.brand-product-label { padding: 0 22px 14px; margin-top: -6px; }
.app-shell.sidebar-collapsed .brand-product-label { display: none; }

/* ---------- 29. Page loader (shown on navigation) ---------- */
.page-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(245, 247, 250, 0.82); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  opacity: 0; pointer-events: none; transition: opacity 200ms ease;
}
.page-loader.visible { opacity: 1; pointer-events: all; }
[data-theme="dark"] .page-loader { background: rgba(16, 19, 26, 0.85); }
.page-loader img { width: 84px; animation: loaderPulse 1.15s ease-in-out infinite; }
.page-loader .loader-text { font-size: 12.5px; font-weight: 600; color: var(--text-tertiary); letter-spacing: 0.02em; }
@keyframes loaderPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.65; }
  50% { transform: scale(1.05); opacity: 1; }
}
