/* =====================================================================
   Law-Prac-Management · Design System v1.1 (Easylaw palette)
   No external dependencies - safe for offline / intranet deployment.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Neutrals - charcoal / black, after easylaw.com.my */
  --ink-950: #111111;
  --ink-900: #1c1c1c;
  --ink-800: #262626;
  --ink-700: #333333;
  --ink-600: #474747;
  --ink-500: #6b6b6b;
  --ink-400: #8e8e8e;
  --ink-300: #b8b8b8;
  --ink-200: #dcdcdc;
  --ink-150: #e3e3e3;
  --ink-100: #efefef;
  --ink-50:  #f7f7f7;
  --white:   #ffffff;

  /* Brand - Easylaw red, with their blush tint for soft backgrounds */
  --brand-700: #9c2626;
  --brand-600: #b22d2d;
  --brand-500: #c93333;   /* Easylaw red */
  --brand-100: #f6dcdc;
  --brand-50:  #f9f2f4;   /* Easylaw blush */

  /* Primary actions, links, focus - same red family */
  --primary-700: #9c2626;
  --primary-600: #b22d2d;
  --primary-500: #c93333;
  --primary-100: #f6dcdc;
  --primary-50:  #fbf5f6;

  /* Informational blue (Easylaw link blue) - for neutral status like "To Do" */
  --info-700: #23557f;
  --info-500: #337ab7;
  --info-100: #e1edf7;
  --info-50:  #f1f6fb;

  /* Accent plum (Easylaw secondary) */
  --plum-700: #7a3a47;
  --plum-500: #9d4f5f;
  --plum-100: #f3e3e7;

  --green-700: #3f7a2a; --green-500: #6aa84f; --green-100: #e4f1dd;   /* Easylaw green */
  --amber-700: #8a5a06; --amber-500: #d68f12; --amber-100: #fcefd4;
  --red-700:   #8f1d1d; --red-500:   #d9363e; --red-100:   #fbe2e3;
  --violet-700:#5a37a6; --violet-500:#7c56d6; --violet-100:#ece6fb;
  --teal-700:  #0d6a73; --teal-500:  #179aa6; --teal-100:  #dbf2f4;

  --bg: var(--brand-50);
  --surface: var(--white);
  --surface-2: var(--ink-50);
  --border: #ece4e6;
  --border-strong: var(--ink-200);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --text-faint: var(--ink-400);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .10), 0 2px 6px -2px rgba(0, 0, 0, .05);
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, .25);

  --sidebar-w: 252px;
  --topbar-h: 60px;

  --font: "Lato", "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Montserrat", "Segoe UI", system-ui, Arial, sans-serif;  /* headings & brand, as Easylaw */
  --font-mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;

  --focus: 0 0 0 3px rgba(201, 51, 51, .22);
  --t: 160ms cubic-bezier(.2,.8,.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--primary-700); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-serif); font-weight: 650; letter-spacing: -.01em; color: var(--ink-950); }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 .75em; }
img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 12.5px; }
kbd { padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--white); color: var(--ink-600); font-size: 11px; }
::selection { background: var(--primary-100); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: linear-gradient(180deg, #000000 0%, var(--ink-800) 100%);
  color: var(--ink-300); display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.04);
  transition: transform var(--t);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: var(--white); box-shadow: 0 4px 14px -4px rgba(201,51,51,.55), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { line-height: 1.15; }
.brand-name { font-family: var(--font-serif); font-size: 16px; font-weight: 700; color: var(--white); letter-spacing: .01em; }
.brand-sub { font-size: 11px; color: var(--ink-400); text-transform: uppercase; letter-spacing: .12em; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; scrollbar-width: thin; scrollbar-color: var(--ink-700) transparent; }
.nav-section { font-size: 10.5px; font-weight: 700; color: var(--ink-500); text-transform: uppercase; letter-spacing: .12em; padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0;
  border-radius: 8px; color: var(--ink-300); font-weight: 500; text-decoration: none;
  transition: background var(--t), color var(--t);
}
.nav a:hover { background: rgba(255,255,255,.05); color: var(--white); }
.nav a.active { background: rgba(201,51,51,.20); color: var(--white); box-shadow: inset 2px 0 0 var(--brand-500); }
.nav a.active .icon { color: var(--brand-500); }
.nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; height: 19px; line-height: 19px; border-radius: 10px; background: rgba(255,255,255,.09); color: var(--ink-200); font-size: 11px; font-weight: 600; text-align: center; }
.nav .count.hot { background: var(--red-500); color: var(--white); }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.06); font-size: 11.5px; color: var(--ink-500); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-toggle { display: none; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: min(440px, 100%); height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-2);
  color: var(--text-faint); cursor: pointer; font: inherit; text-align: left; transition: border var(--t), box-shadow var(--t);
}
.search-trigger:hover { border-color: var(--ink-300); }
.search-trigger span { flex: 1; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--ink-600); cursor: pointer; transition: background var(--t);
}
.icon-btn:hover { background: var(--ink-100); color: var(--ink-900); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--red-500); box-shadow: 0 0 0 2px var(--white); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.user-chip:hover { border-color: var(--border-strong); }
.user-chip .meta { line-height: 1.15; text-align: left; }
.user-chip .meta b { display: block; font-size: 13px; font-weight: 600; }
.user-chip .meta small { color: var(--text-muted); font-size: 11.5px; text-transform: capitalize; }

.content { padding: 26px 28px 48px; max-width: 1480px; width: 100%; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header .eyebrow { font-size: 12px; font-weight: 600; color: var(--brand-700); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.page-header p.lead { color: var(--text-muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { color: var(--ink-300); }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 12px; align-items: center; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt-0{margin-top:0}.mt-1{margin-top:6px}.mt-2{margin-top:12px}.mt-3{margin-top:18px}.mt-4{margin-top:26px}
.mb-0{margin-bottom:0}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:18px}
.muted { color: var(--text-muted); } .faint { color: var(--text-faint); } .small { font-size: 12.5px; } .xs { font-size: 11.5px; }
.strong { font-weight: 600; } .right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.text-green{color:var(--green-700)}.text-red{color:var(--red-700)}.text-amber{color:var(--amber-700)}

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 15px; }
.card-header .sub { color: var(--text-muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Stats ---------- */
.stat { position: relative; padding: 18px 20px; overflow: hidden; }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; color: var(--ink-950); font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.stat .glyph { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.glyph.blue { background: var(--info-100); color: var(--info-500); }
.glyph.green { background: var(--green-100); color: var(--green-700); }
.glyph.amber { background: var(--amber-100); color: var(--amber-700); }
.glyph.red { background: var(--red-100); color: var(--red-700); }
.glyph.violet { background: var(--violet-100); color: var(--violet-700); }
.glyph.brass { background: var(--brand-100); color: var(--brand-700); }
.glyph.teal { background: var(--teal-100); color: var(--teal-700); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background var(--t), border-color var(--t), box-shadow var(--t), color var(--t), transform 80ms;
  text-decoration: none !important; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-500); color: var(--white); box-shadow: 0 1px 2px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.08); }
.btn-primary:hover { background: var(--brand-600); color: var(--white); }
.btn-accent { background: var(--green-500); color: var(--white); }
.btn-accent:hover { background: var(--green-700); color: var(--white); }
.btn-secondary { background: var(--surface); color: var(--ink-800); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--ink-50); border-color: var(--ink-300); color: var(--ink-900); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-danger { background: var(--red-500); color: var(--white); }
.btn-danger:hover { background: var(--red-700); color: var(--white); }
.btn-success { background: var(--green-500); color: var(--white); }
.btn-success:hover { background: var(--green-700); color: var(--white); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--ink-100); color: var(--ink-700);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge-gray   { background: var(--ink-100); color: var(--ink-600); }
.badge-blue   { background: var(--info-100); color: var(--info-700); }
.badge-green  { background: var(--green-100); color: var(--green-700); }
.badge-amber  { background: var(--amber-100); color: var(--amber-700); }
.badge-red    { background: var(--red-100); color: var(--red-700); }
.badge-violet { background: var(--violet-100); color: var(--violet-700); }
.badge-teal   { background: var(--teal-100); color: var(--teal-700); }
.badge-brass  { background: var(--brand-100); color: var(--brand-700); }
.badge-plum   { background: var(--plum-100); color: var(--plum-700); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--ink-100); color: var(--ink-600); border: 1px solid var(--border); }
.tag-source { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-700); }
.field .req { color: var(--red-500); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--text-faint); }
.field .error { font-size: 12px; color: var(--red-700); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--white); color: var(--text); font: inherit; font-size: 13.5px;
  transition: border-color var(--t), box-shadow var(--t);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6782' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.select[multiple] { height: auto; min-height: 110px; padding: 6px; background-image: none; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary-500); box-shadow: var(--focus); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red-500); }
.input-sm, .select.input-sm { height: 32px; font-size: 13px; border-radius: 8px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon { position: absolute; left: 11px; color: var(--text-faint); pointer-events: none; }
.input-group .input { padding-left: 36px; }
.input-affix { display: flex; }
.input-affix .affix { display: grid; place-items: center; padding: 0 11px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 9px 0 0 9px; background: var(--surface-2); color: var(--text-muted); font-size: 13px; font-weight: 600; }
.input-affix .input { border-radius: 0 9px 9px 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--ink-900); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--ink-100); border-radius: 10px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-600); cursor: pointer; }
.segmented input:checked + span { background: var(--white); color: var(--ink-900); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }
.form-section { padding: 22px 24px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section-head { margin-bottom: 16px; }
.form-section-head h3 { font-size: 14px; }
.form-section-head p { color: var(--text-muted); font-size: 12.5px; margin: 2px 0 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .input, .toolbar .select { height: 34px; font-size: 13px; }
.toolbar .select { width: auto; min-width: 140px; }
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 13px 12px; color: var(--text-muted); font-weight: 600; font-size: 13px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink-900); }
.tabs a.active { color: var(--ink-950); }
.tabs a.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand-500); }
.tabs .num { padding: 0 7px; border-radius: 10px; background: var(--ink-100); color: var(--ink-600); font-size: 11px; line-height: 18px; }
.tabs a.active .num { background: var(--ink-900); color: var(--white); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1; padding: 10px 16px; text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table th a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--t); }
.table tbody tr:hover { background: var(--primary-50); }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-title { font-weight: 600; color: var(--ink-950); }
.table .cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.table-compact td { padding: 8px 14px; } .table-compact th { padding: 8px 14px; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.overdue { color: var(--red-700); font-weight: 600; }
.due-soon { color: var(--amber-700); font-weight: 600; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; }
.pager nav { display: flex; gap: 4px; }
.pager a, .pager span.cur { min-width: 32px; height: 32px; padding: 0 9px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--ink-700); font-weight: 600; text-decoration: none; background: var(--white); }
.pager a:hover { border-color: var(--ink-300); }
.pager span.cur { background: var(--ink-900); border-color: var(--ink-900); color: var(--white); }
.pager span.gap { padding: 0 4px; align-self: center; }

/* ---------- Avatar ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--white); flex: none; letter-spacing: .02em; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.person { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.person .name { font-weight: 600; color: var(--ink-900); }
.person .sub { font-size: 12px; color: var(--text-muted); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--white); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Description list ---------- */
.dl { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 0; font-size: 13.5px; }
.dl dt { padding: 10px 0; color: var(--text-muted); font-weight: 500; border-bottom: 1px dashed var(--border); }
.dl dd { margin: 0; padding: 10px 0; border-bottom: 1px dashed var(--border); color: var(--ink-900); word-break: break-word; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }

/* ---------- Alerts & flash ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 10px; border: 1px solid; font-size: 13.5px; margin-bottom: 18px; }
.alert .icon { margin-top: 1px; }
.alert-info    { background: var(--info-50); border-color: var(--info-100); color: var(--info-700); }
.alert-success { background: var(--green-100); border-color: #c9e3bd; color: var(--green-700); }
.alert-warning { background: var(--amber-100); border-color: #f4dba7; color: var(--amber-700); }
.alert-danger  { background: var(--red-100); border-color: #f4c3ca; color: var(--red-700); }
.alert b { font-weight: 700; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; gap: 12px; align-items: flex-start; width: 360px; max-width: calc(100vw - 40px); padding: 14px 16px;
  background: var(--ink-950); color: var(--ink-100); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: toast-in 260ms cubic-bezier(.2,.9,.3,1.2);
}
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: #9fd486; } .toast.error .icon { color: #ff8a8a; } .toast.info .icon { color: #8fc0ec; } .toast.warning .icon { color: #f6c25e; }
.toast .msg { flex: 1; font-size: 13.5px; }
.toast button { background: none; border: 0; color: var(--ink-400); cursor: pointer; padding: 0; }
.toast.hide { animation: toast-out 200ms forwards; }
@keyframes toast-in { from { transform: translateY(12px) scale(.97); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(30px); opacity: 0; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty .art { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-items: center; background: var(--ink-100); color: var(--ink-400); }
.empty .art .icon { width: 28px; height: 28px; }
.empty h3 { font-size: 15px; margin-bottom: 4px; }
.empty p { color: var(--text-muted); max-width: 380px; margin: 0 auto 16px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; }
.modal-backdrop.open { display: flex; animation: fade-in 140ms; }
.modal { width: 520px; max-width: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: modal-in 200ms cubic-bezier(.2,.9,.3,1.1); }
.modal-lg { width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { transform: translateY(14px) scale(.98); opacity: 0; } }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 60; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: none; }
.dropdown.open .dropdown-menu { display: block; animation: modal-in 140ms; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--ink-800); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; text-decoration: none; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--ink-100); }
.dropdown-menu .divider { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-menu .head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

/* ---------- Command palette ---------- */
.palette { width: 620px; }
.palette input { width: 100%; height: 56px; padding: 0 20px 0 52px; border: 0; border-bottom: 1px solid var(--border); font: inherit; font-size: 16px; border-radius: 16px 16px 0 0; outline: none; }
.palette .p-icon { position: absolute; left: 20px; top: 19px; color: var(--text-faint); }
.palette-list { max-height: 380px; overflow-y: auto; padding: 8px; }
.palette-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--ink-800); text-decoration: none; }
.palette-list a.sel, .palette-list a:hover { background: var(--primary-50); color: var(--ink-950); }
.palette-list .grp { padding: 10px 12px 4px; font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .1em; }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .t-dot { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--ink-100); color: var(--ink-600); }
.timeline .t-dot .icon { width: 14px; height: 14px; }
.timeline .t-body { flex: 1; min-width: 0; padding-top: 4px; font-size: 13.5px; }
.timeline .t-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.timeline .t-note { margin-top: 6px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; white-space: pre-wrap; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 8px; background: var(--ink-100); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--brand-500), var(--plum-500)); transition: width 300ms ease; }
.progress.green > span { background: var(--green-500); }
.progress.brass > span { background: linear-gradient(90deg, var(--brand-500), var(--brand-700)); }

/* ---------- Charts ---------- */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--border); }
.chart .grid-line { stroke: var(--ink-100); stroke-dasharray: 3 4; }
.chart text { fill: var(--ink-500); font-size: 11px; font-family: var(--font); }
.chart .bar { transition: opacity var(--t); }
.chart .bar:hover { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--ink-600); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-tip { position: fixed; z-index: 120; pointer-events: none; padding: 7px 10px; background: var(--ink-950); color: var(--white); border-radius: 8px; font-size: 12px; box-shadow: var(--shadow-md); white-space: nowrap; display: none; }
.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut-wrap .chart { width: 170px; flex: none; }
.chart .donut-center { font-size: 26px; font-weight: 700; fill: var(--ink-950); }
.heat td.h { text-align: center; font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list a.item-link { color: inherit; text-decoration: none; display: block; }
.list a.item-link:hover .t { color: var(--primary-600); }
.list .t { font-weight: 600; color: var(--ink-900); }
.list .s { font-size: 12px; color: var(--text-muted); }

/* ---------- Files / dropzone ---------- */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 28px 20px; border: 2px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2);
  text-align: center; color: var(--text-muted); cursor: pointer; transition: border-color var(--t), background var(--t);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary-500); background: var(--primary-50); color: var(--primary-700); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--white); box-shadow: var(--shadow-sm); color: var(--primary-600); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--white); }
.file-item .ft { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: .04em; color: var(--white); background: var(--ink-500); flex: none; }
.ft.pdf { background: #c93333; } .ft.img { background: #179aa6; } .ft.doc { background: #337ab7; } .ft.xls { background: #6aa84f; } .ft.url { background: #9d4f5f; }
.file-item .fname { font-weight: 600; color: var(--ink-900); word-break: break-all; }
.file-item .fmeta { font-size: 12px; color: var(--text-muted); }
.file-item .grow { flex: 1; min-width: 0; }
.upload-row .progress { margin-top: 6px; }

/* ---------- Timesheet editor ---------- */
.entries-table td { padding: 8px 10px; vertical-align: top; }
.entries-table .input, .entries-table .select { height: 34px; font-size: 13px; }
.entries-table .textarea { min-height: 34px; height: 34px; padding: 7px 10px; }
.entries-table .dur { font-variant-numeric: tabular-nums; font-weight: 600; padding-top: 16px; white-space: nowrap; }
.entries-table tr.overlap td { background: var(--red-100); }
.ts-summary { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.ts-summary .big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-cell { padding: 10px; border: 1px solid var(--border); border-radius: 11px; background: var(--white); text-decoration: none !important; color: inherit; transition: border var(--t), box-shadow var(--t); }
.day-cell:hover { border-color: var(--primary-500); box-shadow: var(--shadow-sm); }
.day-cell .dname { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; }
.day-cell .dnum { font-size: 18px; font-weight: 700; color: var(--ink-900); }
.day-cell .dhrs { font-size: 12px; color: var(--text-muted); }
.day-cell.today { border-color: var(--brand-500); box-shadow: inset 0 0 0 1px var(--brand-500); }
.day-cell.has { background: var(--green-100); border-color: #c9e3bd; }
.day-cell.weekend { background: var(--surface-2); }

/* ---------- Import center ---------- */
.import-card { display: flex; flex-direction: column; }
.import-card .card-body { flex: 1; }
.import-src { display: flex; align-items: center; gap: 14px; }
.import-src .logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--white); }
.logo.kiv { background: linear-gradient(135deg, #c93333, #9c2626); }
.logo.si { background: linear-gradient(135deg, #333333, #000000); }
.logo.folder { background: linear-gradient(135deg, #9d4f5f, #7a3a47); }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-300); }
.conn.ok { color: var(--green-700); } .conn.ok::before { background: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.conn.bad { color: var(--red-700); } .conn.bad::before { background: var(--red-500); box-shadow: 0 0 0 3px var(--red-100); }
.job { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.job:last-child { border-bottom: 0; }
.job .jt { font-weight: 600; } .job .jd { font-size: 12px; color: var(--text-muted); }
.job .jstats { grid-column: 1 / -1; display: none; }
.job.running .jstats, .job.done .jstats { display: block; }
.jcounts { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.jcounts b { color: var(--ink-900); font-variant-numeric: tabular-nums; }

/* ---------- Kanban-ish status chips ---------- */
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.prio .bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.prio .bars i { width: 3px; border-radius: 1px; background: var(--ink-200); }
.prio .bars i:nth-child(1) { height: 5px; } .prio .bars i:nth-child(2) { height: 8px; } .prio .bars i:nth-child(3) { height: 12px; }
.prio.low .bars i:nth-child(1) { background: var(--ink-500); }
.prio.normal .bars i:nth-child(-n+2) { background: var(--primary-500); }
.prio.high .bars i { background: var(--amber-500); }
.prio.urgent .bars i { background: var(--red-500); }
.prio.urgent { color: var(--red-700); }
.sentiment { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.sentiment .face { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; }
.sentiment.normal .face { background: var(--green-100); } .sentiment.unhappy .face { background: var(--amber-100); } .sentiment.angry .face { background: var(--red-100); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--white); }
.auth-art {
  position: relative; overflow: hidden; padding: 48px 56px; color: var(--ink-200);
  background: radial-gradient(1200px 600px at 10% 110%, rgba(201,51,51,.35), transparent 60%),
              radial-gradient(900px 500px at 110% -10%, rgba(157,79,95,.30), transparent 60%),
              linear-gradient(160deg, #000000, var(--ink-800));
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth-art h1 { font-family: var(--font-serif); font-size: 40px; line-height: 1.15; font-weight: 500; color: var(--white); max-width: 520px; letter-spacing: -.01em; }
.auth-art h1 em { font-style: italic; color: var(--brand-500); }
.auth-art .points { display: grid; gap: 14px; margin-top: 34px; max-width: 460px; position: relative; z-index: 1; }
.auth-art .point { display: flex; gap: 14px; align-items: flex-start; }
.auth-art .point .pi { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.07); color: var(--brand-500); border: 1px solid rgba(255,255,255,.08); }
.auth-art .point b { color: var(--white); display: block; font-weight: 600; }
.auth-art .point span { font-size: 13px; color: var(--ink-400); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h2 { font-size: 24px; margin-bottom: 6px; }
.auth-box .lead { color: var(--text-muted); margin-bottom: 28px; }
.auth-box .field { margin-bottom: 16px; }
.auth-box .input { height: 44px; }
.auth-box .btn { height: 44px; }
.auth-foot { margin-top: 28px; font-size: 12px; color: var(--text-faint); text-align: center; }

/* ---------- Docs ---------- */
.doc-layout { display: grid; grid-template-columns: 230px minmax(0,1fr); gap: 24px; align-items: start; }
.doc-nav { position: sticky; top: calc(var(--topbar-h) + 20px); }
.doc-nav a { display: block; padding: 7px 12px; border-radius: 8px; color: var(--ink-600); font-weight: 500; text-decoration: none; }
.doc-nav a:hover { background: var(--ink-100); }
.doc-nav a.active { background: var(--ink-900); color: var(--white); }
.prose { font-size: 14.5px; line-height: 1.7; color: var(--ink-800); }
.prose h1 { font-size: 26px; margin: 0 0 12px; } .prose h2 { font-size: 19px; margin: 32px 0 10px; padding-top: 8px; border-top: 1px solid var(--border); } .prose h3 { font-size: 15.5px; margin: 22px 0 8px; }
.prose ul, .prose ol { padding-left: 22px; } .prose li { margin: 4px 0; }
.prose code { background: var(--ink-100); padding: 1px 6px; border-radius: 5px; }
.prose pre { background: var(--ink-950); color: var(--ink-150); padding: 16px 18px; border-radius: 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13.5px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose blockquote { margin: 14px 0; padding: 12px 16px; border-left: 3px solid var(--brand-500); background: var(--brand-50); border-radius: 0 10px 10px 0; color: var(--ink-700); }

/* ---------- Setup ---------- */
.setup { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(900px 500px at 50% -10%, rgba(201,51,51,.14), transparent 60%), var(--brand-50); }
.setup .card { width: 640px; max-width: 100%; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.checklist .ok { color: var(--green-700); } .checklist .bad { color: var(--red-700); }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .toolbar, .pager, .no-print { display: none !important; }
  .main { margin: 0; } .content { padding: 0; } .card { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .menu-toggle { display: grid; }
  .content { padding: 20px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .doc-layout { grid-template-columns: 1fr; } .doc-nav { position: static; }
  .user-chip .meta { display: none; }
  .search-trigger span, .search-trigger kbd { display: none; } .search-trigger { width: 38px; padding: 0; justify-content: center; }
}
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; } .dl dt { border-bottom: 0; padding-bottom: 0; }
  .week-strip { grid-template-columns: repeat(4, 1fr); }
}
