:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #f8f9fb;
  --border: #e2e6ed;
  --border2: #d0d6e0;
  --accent: #1a56db;
  --accent-light: #eff4ff;
  --accent3: #059669;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warn: #d97706;
  --warn-light: #fffbeb;
  --text: #111827;
  --text2: #374151;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --sidebar-bg: #1e2535;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-border: rgba(255,255,255,0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; overflow: hidden; }

/* ── LOGIN SCREEN ────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 400px; box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}
.login-logo {
  margin-bottom: 0;
}
.login-firm { font-size: 12px; color: var(--muted); margin-bottom: 32px; }
.login-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; display: block; }
.login-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; font-family: 'DM Sans', sans-serif;
  outline: none; transition: border-color 0.12s, box-shadow 0.12s; margin-bottom: 16px;
}
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.login-btn {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 12px; font-size: 14px; font-weight: 600;
  font-family: 'DM Sans', sans-serif; cursor: pointer; transition: background 0.13s;
  margin-top: 4px;
}
.login-btn:hover { background: #1648c0; }
.login-btn:disabled { background: var(--muted2); cursor: not-allowed; }
.login-error {
  background: var(--danger-light); border: 1px solid #fecaca; border-radius: 6px;
  padding: 10px 12px; font-size: 12px; color: var(--danger); margin-bottom: 16px; display: none;
}
.pw-wrap { position: relative; margin-bottom: 16px; }
.pw-wrap .login-input { margin-bottom: 0; padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--muted); font-size: 14px; user-select: none;
}

/* ── CHANGE PASSWORD SCREEN ──────────────────────────────── */
#change-pw-screen {
  position: fixed; inset: 0; background: rgba(15,23,42,0.6);
  display: none; align-items: center; justify-content: center; z-index: 900;
}
.change-pw-card {
  background: #fff; border-radius: 16px; padding: 36px;
  width: 400px; box-shadow: 0 24px 80px rgba(0,0,0,0.2);
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 224px; min-width: 224px; background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 100;
}
.logo { padding: 16px 16px 14px; border-bottom: 1px solid var(--sidebar-border); display: flex; align-items: center; }
.logo-mark { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 13px; color: #fff; letter-spacing: 0.02em; line-height: 1.3; }
.logo-sub { font-size: 9px; color: var(--sidebar-muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 3px; }
.sidebar-section { padding: 14px 12px 6px; }
.sidebar-section-label { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sidebar-muted); padding: 0 8px; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--sidebar-text); transition: all 0.13s; user-select: none; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 13px; width: 17px; text-align: center; }
.sidebar-divider { height: 1px; background: var(--sidebar-border); margin: 8px 12px; }
#sidebar-work-types { padding: 0 0 4px; }

.user-info {
  margin-top: auto; border-top: 1px solid var(--sidebar-border);
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 12px; color: #fff; font-weight: 600; }
.user-role { font-size: 10px; color: var(--sidebar-muted); }
.logout-btn { margin-left: auto; font-size: 11px; color: var(--sidebar-muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* ── MAIN ────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 54px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.topbar-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); flex: 1; }
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.badge-owner   { background: #eff4ff; color: #1a56db; border: 1px solid #c7d7fa; }
.badge-manager { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }
.badge-senior  { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-employee{ background: #f0fdf4; color: #059669; border: 1px solid #bbf7d0; }

.btn { padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; transition: all 0.13s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1648c0; }
.btn-ghost { background: var(--surface); color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { border-color: var(--muted); background: var(--surface2); }
.btn-sm { padding: 5px 11px; font-size: 11px; }
.btn-danger-soft { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }

.content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.view { display: none; }
.view.active { display: block; }

/* ── KPI CARDS ───────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 16px; position: relative; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.kpi-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; border-radius: 10px 10px 0 0; }
.kpi-card.kpi-info::before { background: var(--accent); }
.kpi-card.kpi-warn::before { background: var(--warn); }
.kpi-card.kpi-danger::before { background: var(--danger); }
.kpi-card.kpi-ok::before { background: var(--accent3); }
.kpi-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px; font-weight: 600; }
.kpi-value { font-family: 'Syne', sans-serif; font-size: 30px; font-weight: 800; line-height: 1; margin-bottom: 5px; }
.kpi-sub { font-size: 11px; color: var(--muted); }

/* ── TABS ────────────────────────────────────────────────── */
.tabs { display: flex; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab { padding: 8px 16px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.13s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── FILTER BAR ──────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filter-select { background: var(--surface); border: 1px solid var(--border2); color: var(--text2); border-radius: 7px; padding: 7px 10px; font-size: 12px; font-family: 'DM Sans', sans-serif; cursor: pointer; outline: none; }
.search-input { background: var(--surface); border: 1px solid var(--border2); color: var(--text); border-radius: 7px; padding: 7px 12px; font-size: 12px; font-family: 'DM Sans', sans-serif; outline: none; width: 220px; }
.search-input:focus { border-color: var(--accent); }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.table-wrap table { width: 100%; border-collapse: collapse; }
thead th { padding: 11px 16px; text-align: left; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface2); }
thead th:hover { color: var(--accent); background: var(--accent-light); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f0f5ff; }
tbody td { padding: 12px 16px; font-size: 13px; vertical-align: middle; color: var(--text2); }

/* ── STATUS + PRIORITY CHIPS ─────────────────────────────── */
.status-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 4px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.s-not-started  { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.s-waiting      { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.s-in-progress  { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.s-review       { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.s-done         { background: #f0fdf4; color: #065f46; border: 1px solid #bbf7d0; }
.s-billing      { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.s-billed       { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.s-nonbillable  { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.s-paid         { background: #f0fdf4; color: #14532d; border: 1px solid #86efac; font-weight:700; }
.priority-chip  { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.p-high   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.p-medium { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.p-low    { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.wt-chip  { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-family: 'DM Mono', monospace; font-weight: 500; background: #eff4ff; border: 1px solid #c7d7fa; color: #1a56db; }
.overdue  { color: var(--danger) !important; font-weight: 600; }

/* ── DETAIL PANEL ────────────────────────────────────────── */
.panel-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.3); z-index: 200; display: none; align-items: flex-start; justify-content: flex-end; }
.panel-overlay.open { display: flex; }
.detail-panel { width: 520px; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; animation: slideIn 0.2s ease; box-shadow: -4px 0 24px rgba(0,0,0,0.08); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.panel-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; background: var(--surface2); }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }
.close-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border2); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.12s; }
.close-btn:hover { color: var(--text); border-color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.field-value { font-size: 13px; color: var(--text2); font-weight: 500; }
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; margin-bottom: 6px; transition: border-color 0.12s; }
.task-item:hover { border-color: var(--accent); }
.task-check { width: 16px; height: 16px; min-width: 16px; border-radius: 4px; border: 1.5px solid var(--border2); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 10px; transition: all 0.12s; background: white; margin-top: 1px; }
.task-check.checked { background: var(--accent3); border-color: var(--accent3); color: #fff; }
.task-name { font-size: 13px; color: var(--text2); }
.task-name.done { text-decoration: line-through; color: var(--muted2); }
.task-note-text { font-size: 10px; color: #6b7280; margin-top: 2px; font-style: italic; }
.task-meta { font-size: 10px; color: var(--muted2); margin-top: 1px; }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 400; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); animation: modalIn 0.18s ease; }
@keyframes modalIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface2); border-radius: 12px 12px 0 0; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface2); border-radius: 0 0 12px 12px; }
.modal-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; color: var(--text); }
.form-group { margin-bottom: 14px; }
.form-label { font-size: 11px; color: var(--muted); margin-bottom: 5px; display: block; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.form-input, .form-select { width: 100%; background: var(--surface); border: 1px solid var(--border2); border-radius: 7px; padding: 8px 12px; color: var(--text); font-size: 13px; font-family: 'DM Sans', sans-serif; outline: none; transition: border-color 0.12s, box-shadow 0.12s; }
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,86,219,0.08); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea.form-input { resize: vertical; min-height: 60px; }

/* ── DASH CARDS ──────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.dash-card-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.stuck-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text2); }
.stuck-item:last-child { border-bottom: none; }
.workload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.workload-name { width: 130px; color: var(--text2); font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workload-bar-wrap { flex: 1; background: var(--surface2); border-radius: 3px; height: 6px; overflow: hidden; border: 1px solid var(--border); }
.workload-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s; }
.workload-count { width: 20px; text-align: right; font-size: 11px; font-weight: 600; font-family: 'DM Mono', monospace; }

/* ── ACTIVITY LOG ────────────────────────────────────────── */
.activity-entry { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.activity-entry:last-child { border-bottom: none; }
.activity-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.activity-text { font-size: 12px; color: var(--text); font-weight: 500; }
.activity-detail { font-size: 11px; color: var(--muted); margin-top: 1px; font-style: italic; }
.activity-meta { font-size: 10px; color: var(--muted2); margin-top: 2px; }

/* ── MISC ────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 32px; color: var(--muted); font-size: 13px; }
.empty-icon { font-size: 32px; margin-bottom: 8px; }
.notif-dot { width: 6px; height: 6px; background: var(--danger); border-radius: 50%; display: inline-block; margin-left: 4px; vertical-align: middle; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.section-count { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MOBILE RESPONSIVE ───────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  body { flex-direction: row; overflow: hidden; }
  .main { width: 100vw; height: 100vh; flex-direction: column; overflow: hidden; }
  .topbar { padding: 0 12px; height: 52px; flex-shrink: 0; }
  .topbar-title { font-size: 13px; }
  .badge { font-size: 9px; padding: 2px 7px; }
  .content { padding: 12px; height: calc(100vh - 52px - 60px); overflow-y: auto; }
  #mobile-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 60px; background: var(--sidebar-bg);
    display: flex; align-items: center; justify-content: space-around;
    border-top: 1px solid var(--sidebar-border); z-index: 500;
  }
  .mobile-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    cursor: pointer; padding: 6px 12px; border-radius: 8px;
    color: var(--sidebar-muted); font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .mobile-nav-item .nav-icon { font-size: 20px; }
  .mobile-nav-item.active { color: #fff; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); gap: 8px; margin-bottom: 12px; }
  .kpi-value { font-size: 22px; }
  .dash-grid { grid-template-columns: 1fr; gap: 12px; }
  .filter-bar { flex-direction: column; gap: 8px; }
  .search-input { width: 100%; }
  .filter-select { width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 580px; }
  .panel-overlay { align-items: flex-end; }
  .detail-panel { width: 100vw; max-height: 92vh; height: auto; border-radius: 20px 20px 0 0; border-left: none; border-top: 1px solid var(--border); animation: slideUp 0.22s ease; }
  @keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  .modal { width: calc(100vw - 24px); margin: 12px; }
  .form-row { grid-template-columns: 1fr; gap: 8px; }
  #new-ticket-btn { font-size: 11px; padding: 5px 10px; }
  .user-row { flex-wrap: wrap; gap: 6px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
}

/* ── ADMIN PANEL ─────────────────────────────────────────── */
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.user-row-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-row-info { flex: 1; }
.user-row-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-row-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.user-row-badge { font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
