/* ============================================================
   JSS PROTOCOL V3 — Modern Corporate SaaS Design System
   Offline-ready: All fonts local, zero CDN dependencies
   ============================================================ */

/* ── 1. LOCAL FONT FACES ────────────────────────────────── */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter/inter-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter/inter-600.woff2') format('woff2');
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter/inter-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter/inter-800.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* ── 2. DESIGN TOKENS ───────────────────────────────────── */
:root,
html[data-theme="dark"] {
  /* — Backgrounds */
  --bg:             #0d1117;
  --bg-surface:     #161b22;
  --bg-elevated:    #1c2128;
  --bg-panel:       #161b22;
  --bg-topbar:      #0d1117;
  --bg-sidebar:     #0d1117;
  --bg-table-head:  #1c2128;
  --bg-row-alt:     rgba(28, 33, 40, 0.45);
  --bg-row-hover:   rgba(38, 45, 54, 0.75);
  --bg-input:       #0d1117;
  --bg-card:        #161b22;
  --bg-btn-primary:       #2563eb;
  --bg-btn-primary-hover: #1d4ed8;
  --bg-btn-hover:         #262d36;
  --bg-nav-active:        rgba(37, 99, 235, 0.12);
  --bg-error:       rgba(185, 28, 28, 0.18);
  --bg-success:     rgba(21, 128, 61, 0.15);

  /* — Accent */
  --accent:         #2563eb;
  --accent-light:   #3b82f6;
  --accent-subtle:  rgba(37, 99, 235, 0.12);
  --accent-hover:   #60a5fa;
  --focus:          #3b82f6;

  /* — Borders */
  --border:         #30363d;
  --border-light:   #21262d;
  --border-strong:  #484f58;

  /* — Text */
  --text:           #e6edf3;
  --text-muted:     #8b949e;
  --text-dim:       #6e7681;

  /* — Status */
  --green:          #22c55e;
  --green-bg:       rgba(34, 197, 94, 0.10);
  --green-dark:     #15803d;
  --amber:          #f59e0b;
  --amber-bg:       rgba(245, 158, 11, 0.10);
  --red:            #ef4444;
  --red-bg:         rgba(239, 68, 68, 0.10);
  --red-dark:       #dc2626;
  --maroon-bg:      rgba(153, 27, 27, 0.18);

  /* — Urgency */
  --critical:       #ef4444;
  --warning:        #f59e0b;
  --normal:         #22c55e;
  --overdue:        #991b1b;
  --danger:         #ef4444;

  /* — Elevation */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.35);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg:  0 20px 40px rgba(0,0,0,0.60);
  --shadow-glow: 0 0 0 3px rgba(37, 99, 235, 0.25);

  /* — Typography */
  --font:  'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:  'Cascadia Code', 'Consolas', 'Courier New', monospace;
  --font-size-base: 15px;
  --line-height-base: 1.6;

  /* — Radii */
  --r-xs: 3px;
  --r-sm: 5px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* — Transitions */
  --t: 150ms ease;
}

html[data-theme="light"] {
  --bg:             #f0f4f8;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f8fafc;
  --bg-panel:       #ffffff;
  --bg-topbar:      #ffffff;
  --bg-sidebar:     #f8fafc;
  --bg-table-head:  #f1f5f9;
  --bg-row-alt:     rgba(241, 245, 249, 0.7);
  --bg-row-hover:   #e2e8f0;
  --bg-input:       #ffffff;
  --bg-card:        #ffffff;
  --bg-btn-primary:       #2563eb;
  --bg-btn-primary-hover: #1d4ed8;
  --bg-btn-hover:         #e2e8f0;
  --bg-nav-active:        rgba(37, 99, 235, 0.08);
  --bg-error:       #fef2f2;
  --bg-success:     #f0fdf4;

  --accent:         #2563eb;
  --accent-light:   #3b82f6;
  --accent-subtle:  rgba(37, 99, 235, 0.08);
  --accent-hover:   #1d4ed8;
  --focus:          #2563eb;

  --border:         #e2e8f0;
  --border-light:   #f1f5f9;
  --border-strong:  #cbd5e1;

  --text:           #0f172a;
  --text-muted:     #475569;
  --text-dim:       #94a3b8;

  --green:          #16a34a;
  --green-bg:       #f0fdf4;
  --green-dark:     #15803d;
  --amber:          #d97706;
  --amber-bg:       #fffbeb;
  --red:            #dc2626;
  --red-bg:         #fef2f2;
  --red-dark:       #b91c1c;
  --maroon-bg:      #fef2f2;

  --critical:       #ef4444;
  --warning:        #d97706;
  --normal:         #16a34a;
  --overdue:        #991b1b;
  --danger:         #ef4444;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 20px 40px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 0 3px rgba(37, 99, 235, 0.20);
}

/* ── 3. RESET & BASE ────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; }
h3 { font-size: 17px; font-weight: 600; }

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--t);
}
a:hover { color: var(--accent-hover); }

[hidden] { display: none !important; }

/* ── 4. PREFERENCES BAR ─────────────────────────────────── */
.prefs-bar {
  position: fixed;
  top: 14px;
  right: 20px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle {
  min-width: 88px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--r);
  font-size: 12px;
}

.lang-toggle .lang-opt {
  opacity: 0.45;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 12px;
  transition: opacity var(--t), color var(--t);
}
.lang-toggle .lang-opt.active {
  opacity: 1;
  color: var(--accent-hover);
}
.lang-toggle .lang-sep {
  opacity: 0.3;
  margin: 0 2px;
}

/* ── 5. BUTTON SYSTEM ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: var(--r);
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--bg-btn-hover);
  border-color: var(--accent-light);
  color: var(--accent-hover);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover {
  background: var(--bg-btn-primary-hover);
  border-color: var(--bg-btn-primary-hover);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
}

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

.btn-danger {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--red);
  background: var(--red-bg);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.20);
  border-color: var(--red);
  color: #fff;
}

.btn-success {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--green);
}
.btn-success:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--green);
  color: #fff;
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

.btn-icon {
  padding: 7px;
  border-radius: var(--r-sm);
}

/* ── 6. FORMS & INPUTS ──────────────────────────────────── */
label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 9px 13px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color var(--t), box-shadow var(--t);
  appearance: none;
}
input[type="text"]:hover,
input[type="password"]:hover,
input[type="date"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover { border-color: var(--border-strong); }

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-glow);
  outline: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-error {
  margin: 10px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: var(--bg-error);
  color: #fca5a5;
  font-size: 13px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-error::before { content: '⚠'; font-size: 14px; }

.form-ok {
  margin: 10px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: var(--green-bg);
  color: var(--green);
  font-size: 13px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-ok::before { content: '✓'; font-size: 14px; font-weight: 700; }

.field-hint {
  margin: 5px 0 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

/* ── 7. LOGIN VIEW ──────────────────────────────────────── */
#login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(37, 99, 235, 0.08) 0%, transparent 70%),
    var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-shell-single { max-width: 420px; }

.login-header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 0;
  padding: 24px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.seal {
  width: 52px;
  height: 52px;
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 14px;
  color: var(--accent-light);
  background: var(--accent-subtle);
  border-radius: var(--r);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.seal-sm {
  width: 36px;
  height: 36px;
  font-size: 11px;
  border-radius: var(--r-sm);
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-light);
  font-weight: 700;
  margin: 0 0 3px;
}

.login-header h1 {
  font-size: 20px;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  margin: 0;
}

.login-form {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-light);
  padding: 24px 28px 28px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.login-form label {
  margin: 0 0 6px;
}
.login-form label + label,
.login-form input + label {
  margin-top: 14px;
}

.login-form input {
  font-size: 14px;
}

.login-form .btn-block {
  margin-top: 20px;
  padding: 11px;
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* ── 8. APP TOPBAR ──────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-topbar);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand strong {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text);
}

.topbar-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
  display: block;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 120px;
}

#current-user-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 9. APP LAYOUT ──────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── 10. SIDEBAR ────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--r);
  transition: background var(--t), color var(--t), border-color var(--t);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.01em;
  border-left: 2px solid transparent;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg-btn-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--bg-nav-active);
  color: var(--accent-hover);
  border-left-color: var(--accent);
}

/* sidebar icons */
.nav-item::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.6;
  transition: opacity var(--t);
}
.nav-item:hover::before, .nav-item.active::before { opacity: 1; }

.nav-item[data-panel="tasks"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' d='M4 6h12M4 10h12M4 14h8'/%3E%3C/svg%3E");
}
.nav-item[data-panel="categories"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Crect x='3' y='3' width='6' height='6' rx='1' stroke='%238b949e' stroke-width='1.5'/%3E%3Crect x='11' y='3' width='6' height='6' rx='1' stroke='%238b949e' stroke-width='1.5'/%3E%3Crect x='3' y='11' width='6' height='6' rx='1' stroke='%238b949e' stroke-width='1.5'/%3E%3Crect x='11' y='11' width='6' height='6' rx='1' stroke='%238b949e' stroke-width='1.5'/%3E%3C/svg%3E");
}
.nav-item[data-panel="users"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Ccircle cx='8' cy='7' r='3' stroke='%238b949e' stroke-width='1.5'/%3E%3Cpath stroke='%238b949e' stroke-width='1.5' d='M2 17c0-3.3 2.7-6 6-6h1'/%3E%3Ccircle cx='15' cy='13' r='3' stroke='%238b949e' stroke-width='1.5'/%3E%3Cpath stroke='%238b949e' stroke-width='1.5' d='M15 10v3M12 13h6'/%3E%3C/svg%3E");
}
.nav-item[data-panel="legend"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='7' stroke='%238b949e' stroke-width='1.5'/%3E%3Cpath stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' d='M10 7v4M10 13v.5'/%3E%3C/svg%3E");
}

/* ── 11. CONTENT AREA ───────────────────────────────────── */
.content {
  padding: 28px 32px;
  overflow-x: auto;
  max-width: 1800px;
}

/* ── 12. PANEL HEAD ─────────────────────────────────────── */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.panel-desc {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── 13. DASHBOARD SUMMARY CARDS ────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--t), box-shadow var(--t);
}
.summary-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.summary-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 16px;
}
.summary-card-icon.total   { background: var(--accent-subtle); }
.summary-card-icon.progress{ background: var(--amber-bg); }
.summary-card-icon.delay   { background: var(--red-bg); }
.summary-card-icon.done    { background: var(--green-bg); }

.summary-card-num {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}
.summary-card-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

/* ── 14. FILTERS ────────────────────────────────────────── */
.filters {
  display: grid;
  grid-template-columns: 180px 220px 1fr;
  gap: 12px;
  margin-bottom: 18px;
  align-items: flex-end;
}

.filters label {
  margin-top: 0;
  margin-bottom: 5px;
}

.search-label { min-width: 0; }

.inline-form {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: flex-end;
}
.inline-form input { max-width: 360px; }
.inline-form label { margin: 0; }

/* ── 15. TABLE SYSTEM ───────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  font-size: 13px;
}

.data-table th {
  background: var(--bg-table-head);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  user-select: none;
}

.data-table td {
  border-bottom: 1px solid var(--border-light);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  transition: background var(--t);
}

.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr:nth-child(even) { background: var(--bg-row-alt); }

.data-table tbody tr:hover td { background: var(--bg-row-hover) !important; }

/* ── 16. TASK TABLE COLUMN WIDTHS ───────────────────────── */
#tasks-table th:nth-child(1),
#tasks-table td:nth-child(1) { width: 150px; min-width: 130px; }

#tasks-table th:nth-child(2),
#tasks-table td:nth-child(2) { width: 130px; }

#tasks-table th:nth-child(3),
#tasks-table td:nth-child(3) { min-width: 200px; max-width: 320px; }

#tasks-table th:nth-child(4),
#tasks-table td:nth-child(4) { width: 100px; white-space: nowrap; }

#tasks-table th:nth-child(5),
#tasks-table td:nth-child(5) { width: 180px; max-width: 200px; }

#tasks-table th:nth-child(6),
#tasks-table td:nth-child(6) { min-width: 320px; }

#tasks-table th:nth-child(7),
#tasks-table td:nth-child(7) { width: 120px; min-width: 110px; }

.task-desc {
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.task-status-cell {
  min-width: 300px;
  white-space: pre-wrap;
  word-break: break-word;
}

.deadline-date {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.assignee-item {
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 3px;
  word-break: break-word;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.assignee-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-light);
  flex-shrink: 0;
  opacity: 0.6;
}
.assignee-item:last-child { margin-bottom: 0; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty-state {
  margin-top: 24px;
  padding: 40px 24px;
  border: 2px dashed var(--border);
  color: var(--text-dim);
  text-align: center;
  border-radius: var(--r-lg);
  font-size: 14px;
}
.empty-state::before {
  content: '📋';
  display: block;
  font-size: 32px;
  margin-bottom: 10px;
}

/* ── 17. URGENCY INDICATORS ─────────────────────────────── */
.urgency-cell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  white-space: normal;
  word-break: break-word;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.urgency-cell small {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.urgency-badge {
  display: inline-flex;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  position: relative;
}
.urgency-badge::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  opacity: 0.3;
}
.urgency-badge.critical        { background: var(--critical); box-shadow: 0 0 6px var(--critical); }
.urgency-badge.critical::after { background: var(--critical); }
.urgency-badge.warning         { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.urgency-badge.warning::after  { background: var(--warning); }
.urgency-badge.normal          { background: var(--normal); }
.urgency-badge.overdue         { background: var(--overdue); box-shadow: 0 0 6px rgba(153,27,27,0.6); }
.urgency-badge.overdue::after  { background: var(--overdue); }

/* Row-level urgency: Left accent bar */
tr.urgency-critical td:first-child { border-left: 3px solid var(--critical); }
tr.urgency-warning  td:first-child { border-left: 3px solid var(--warning); }
tr.urgency-normal   td:first-child { border-left: 3px solid var(--normal); }
tr.urgency-overdue  td:first-child { border-left: 3px solid var(--overdue); }

tr.urgency-overdue  td { background: rgba(153, 27, 27, 0.06) !important; }
tr.urgency-critical td { background: rgba(239, 68, 68, 0.04) !important; }

/* Completed task rows */
tr.task-done td        { background: rgba(21, 128, 61, 0.06) !important; }
tr.task-done td:first-child { border-left: 3px solid var(--green-dark); }
tr.task-done-overdue td { background: rgba(220, 38, 38, 0.06) !important; }
tr.task-done-overdue td:first-child { border-left: 3px solid var(--red-dark); }

/* ── 18. STATUS PILLS ───────────────────────────────────── */
.status-pill-wrap { margin-bottom: 8px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-pill.status-done,
.status-pill.status-done-ontime {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.30);
}
.status-pill.status-done::before,
.status-pill.status-done-ontime::before { background: var(--green); }

.status-pill.status-done-overdue {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.30);
}
.status-pill.status-done-overdue::before { background: var(--red); }

.status-pill.status-progress {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.30);
}
.status-pill.status-progress::before { background: var(--amber); }

.status-pill.status-delay {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.30);
}
.status-pill.status-delay::before { background: var(--red); }

.status-pill.status-default {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-color: var(--border);
}
.status-pill.status-default::before { background: var(--text-dim); }

/* ── 19. LEGEND ─────────────────────────────────────────── */
.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color var(--t);
}
.legend-list li:hover { border-color: var(--border-strong); }

/* ── 20. ACCOUNT MANAGEMENT ─────────────────────────────── */
.account-form {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 22px 24px;
  border-radius: var(--r-lg);
  margin-bottom: 22px;
  max-width: 640px;
  box-shadow: var(--shadow-sm);
}

.account-form h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fio-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.fio-stack label { margin: 0; }

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* ── 21. ASSIGNEE CHECKBOX LIST ─────────────────────────── */
.assignee-list {
  border: 1px solid var(--border);
  background: var(--bg-input);
  max-height: 160px;
  overflow-y: auto;
  border-radius: var(--r);
}

.assignee-item-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--t);
}
.assignee-item-label:hover { background: var(--bg-row-hover); color: var(--text); }
.assignee-item-label input { width: auto; margin: 0; }

/* ── 22. COMMENTS SYSTEM ────────────────────────────────── */
.comments-log {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-left: 2px solid var(--accent);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 12.5px;
  transition: border-color var(--t);
}
.comment-item:hover { border-color: var(--border); }

html[data-theme="light"] .comment-item { background: rgba(0,0,0,0.02); }

.comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-light);
}

.comment-author-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comment-author {
  font-weight: 700;
  color: var(--text);
  font-size: 12.5px;
}

.comment-time {
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 11px;
  background: var(--bg-hover, rgba(255,255,255,0.05));
  padding: 2px 7px;
  border-radius: 20px;
}

.comment-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.comment-btn-sep {
  color: var(--text-dim);
  font-size: 11px;
}

.comment-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--r-xs);
  transition: color var(--t), background var(--t);
}
.comment-btn:hover { color: var(--accent-hover); background: var(--accent-subtle); }
.comment-btn-danger:hover { color: var(--red); background: var(--red-bg); }

.comment-text {
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

/* ── ATTACHED FILES IN COMMENTS (COMPACT BADGE CHIPS) ── */
.comment-files-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.comment-file-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-elevated, #1a2234);
  border: 1px solid var(--border-strong, rgba(255,255,255,0.12));
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  max-width: 100%;
  transition: all var(--t, 0.15s ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .comment-file-item {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.comment-file-item:hover {
  border-color: var(--accent, #3b82f6);
  background: var(--bg-hover, rgba(59,130,246,0.08));
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.comment-file-item .file-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.comment-file-item .file-link {
  color: var(--accent-hover, #60a5fa);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  cursor: pointer;
}

.comment-file-item .file-link:hover {
  text-decoration: underline;
}

.comment-file-item .file-size {
  color: var(--text-dim, #94a3b8);
  font-size: 11px;
  font-family: var(--mono, monospace);
  flex-shrink: 0;
  opacity: 0.85;
}

.comments-history-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--bg-input);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: var(--r);
}

/* ── 23. FILE UPLOAD SYSTEM ─────────────────────────────── */
.file-upload-section {
  margin-top: 14px;
}

.file-drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
  background: var(--bg-input);
}
.file-drop-zone:hover,
.file-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.file-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.file-drop-icon {
  width: 36px;
  height: 36px;
  opacity: 0.4;
}

.file-drop-text {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: auto;
}

.file-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-light);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  pointer-events: auto;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}

.file-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Selected file preview */
.file-selected-preview {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12.5px;
}

.file-preview-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.file-preview-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-size {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.file-preview-remove {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--r-xs);
  font-size: 14px;
  line-height: 1;
  transition: color var(--t);
  flex-shrink: 0;
}
.file-preview-remove:hover { color: var(--red); }

/* File list (history) */
.status-files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--r);
  font-size: 12.5px;
  transition: border-color var(--t);
}
.file-attachment-card:hover { border-color: var(--border-strong); }

.file-attachment-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.file-attachment-info {
  flex: 1;
  min-width: 0;
}

.file-attachment-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-attachment-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-attachment-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* File count badge in task row */
.file-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 2px 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 20px;
}

/* ── 24. MODALS ─────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 9, 0.80);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 200ms ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Wide status modal */
#status-modal .modal-panel {
  width: min(680px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-head h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-head .btn-ghost {
  border-color: transparent;
  padding: 6px 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
}
.modal-head .btn-ghost:hover { color: var(--text); background: var(--bg-btn-hover); }

.modal-body {
  padding: 20px 22px 22px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.quick-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* executor badge in status modal */
.executor-only-badge label {
  margin: 0 0 6px;
}

/* ── 25. UTILITY ────────────────────────────────────────── */
code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--accent-hover);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-blue   { background: var(--accent-subtle); color: var(--accent-light); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-gray   { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }
.badge-red    { background: var(--red-bg); color: var(--red); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── 26. RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 24px; }
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px;
    gap: 4px;
    overflow-x: auto;
  }

  .nav-item {
    border-left: 0;
    border-bottom: 2px solid transparent;
    flex: 0 0 auto;
    border-radius: var(--r-sm);
    width: auto;
  }
  .nav-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
    background: var(--bg-nav-active);
  }
  .nav-item::before { display: none; }

  .filters { grid-template-columns: 1fr 1fr; }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .panel-actions { width: 100%; }

  .topbar {
    height: auto;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .topbar-user {
    margin-right: 0;
    flex-wrap: wrap;
  }

  .summary-cards { grid-template-columns: repeat(2, 1fr); }

  .prefs-bar { top: auto; bottom: 16px; right: 16px; }
}

@media (max-width: 600px) {
  .filters { grid-template-columns: 1fr; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 14px 12px; }
  .account-grid { grid-template-columns: 1fr; }
  .modal-panel { border-radius: var(--r-lg); }
}

@media (max-width: 480px) {
  .summary-cards { grid-template-columns: 1fr; }
}
