:root {
  --brand: #4F46E5;
  --brand-dark: #4338CA;
  --brand-soft: #EEF2FF;
  --brand-ink: #4338CA;
  --accent-cyan: #00DEF0;
  --accent-coral: #ED7E63;
  --sidebar-bg: #1D1C56;
  --bg: #F0F1F6;
  --surface: #FFFFFF;
  --surface-alt: #F9FAFB;
  --border: #E5E7EB;
  --border-soft: #F3F4F6;
  --text: #1F2937;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;
  --hover: #F3F4F6;
  --shadow: rgba(16,24,40,0.04);
  --overlay: rgba(16,24,40,0.4);
}
[data-theme="dark"] {
  --brand: #6366F1;
  --brand-dark: #5457E5;
  --brand-soft: #25266B;
  --brand-ink: #C7D2FE;
  --sidebar-bg: #1D1C56;
  --bg: #0F1420;
  --surface: #171E2C;
  --surface-alt: #1C2434;
  --border: #2A3446;
  --border-soft: #232C3D;
  --text: #E5E7EB;
  --text-muted: #9CA3AF;
  --text-faint: #6B7280;
  --hover: #232C3D;
  --shadow: rgba(0,0,0,0.3);
  --overlay: rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 500px at 12% 8%, rgba(0,222,240,0.16), transparent 60%),
    radial-gradient(800px 480px at 92% 96%, rgba(237,126,99,0.16), transparent 60%),
    linear-gradient(135deg, #1D1C56 0%, #26246E 55%, #1D1C56 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 18px 50px rgba(8,8,40,0.45);
}
.login-brand { display: flex; align-items: center; justify-content: center; margin-bottom: 22px; background: #1D1C56; border-radius: 10px; padding: 10px 14px; }
.login-brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); }
.login-brand span { font-weight: 600; font-size: 15px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field input, .field select {
  height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; width: 100%;
}
.field input[type="checkbox"], .field input[type="radio"], .field input[type="file"] { width: auto; height: auto; }
.btn-primary {
  width: 100%; height: 40px; border: none; border-radius: 6px;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 14px;
}
.btn-primary:hover { background: var(--brand-dark); }
.form-error {
  background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA;
  border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
}
.form-ok {
  background: #D1FAE5; color: #047857; border: 1px solid #A7F3D0;
  border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
}

/* ---------- App shell ---------- */
#app-screen { display: flex; min-height: 100vh; }
aside#sidebar {
  width: 244px; flex: 0 0 244px; background: var(--sidebar-bg);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; align-self: flex-start; border-right: 1px solid rgba(255,255,255,0.06);
  padding: 16px; display: flex; flex-direction: column; gap: 20px; color: #fff;
}
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 8px; }
.sidebar-brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); }
.sidebar-brand .txt { display: flex; flex-direction: column; }
.sidebar-brand .txt b { font-size: 14px; color: var(--text); }
.sidebar-brand .txt span { font-size: 11px; color: var(--text-faint); }
nav.side-nav { display: flex; flex-direction: column; gap: 2px; }
nav.side-nav button {
  border: none; background: transparent; text-align: left; height: 34px;
  padding: 0 10px; border-radius: 6px; font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.72);
}
nav.side-nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
nav.side-nav button.active { background: rgba(255,255,255,0.13); color: #fff; box-shadow: inset 3px 0 0 var(--accent-cyan); }
.role-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.role-director { background: #EDE9FE; color: #5B21B6; }
.role-manager { background: var(--brand-soft); color: var(--brand-ink); }
.role-team { background: var(--border-soft); color: var(--text-muted); }

.sidebar-user { margin-top: auto; border: 1px solid rgba(255,255,255,0.16); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: rgba(255,255,255,0.04); }
.sidebar-user .who { font-size: 12px; font-weight: 600; color: #fff; }
.sidebar-user .email { font-size: 10.5px; color: rgba(255,255,255,0.62); overflow-wrap: anywhere; }
.sidebar-user button { height: 30px; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; background: rgba(255,255,255,0.08); color: #fff; font-size: 12px; }
.sidebar-user button:hover { background: rgba(255,255,255,0.16); }
.sidebar-user .role-badge { align-self: flex-start; }

main#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header#topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
header#topbar h1 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text); }
#page-body { padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.card .label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.card .num { font-size: 24px; font-weight: 600; color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); color: var(--text); }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); }
thead th { background: var(--surface-alt); font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill-todo { background: var(--border-soft); color: var(--text-muted); }
.pill-progress { background: #FEF3C7; color: #B45309; }
.pill-review { background: var(--brand-soft); color: var(--brand-ink); }
.pill-hold { background: #FEE2E2; color: #B91C1C; }
.pill-done { background: #D1FAE5; color: #047857; }
.pill-active { background: #D1FAE5; color: #047857; }
.pill-suspended { background: #FEE2E2; color: #B91C1C; }
.pill-high { background: #FEE2E2; color: #B91C1C; }
.pill-medium { background: #FEF3C7; color: #B45309; }
.pill-low { background: var(--border-soft); color: var(--text-muted); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; text-decoration: none; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text-muted); }
.comment-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 6px;
  border-radius: 999px; background: #EF4444; color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
}
.btn:hover { background: var(--hover); }
.btn-blue { border: none; background: var(--brand); color: #fff; font-weight: 600; }
.btn-blue:hover { background: var(--brand-dark); }
.spacer { flex: 1; }

.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: 100%; max-width: 480px; background: var(--surface); border-radius: 10px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: center; color: var(--text); }
.modal-header button { border: none; background: transparent; font-size: 18px; color: var(--text-muted); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-alt); display: flex; justify-content: flex-end; gap: 8px; }

.empty-state { padding: 40px; text-align: center; color: var(--text-faint); font-size: 13px; }

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.6);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 30px; padding: 0 10px; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85); font-size: 12px;
}
.theme-toggle:hover { background: rgba(255,255,255,0.16); }

/* ---------- Notification toast ---------- */
#notif-toast {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 13px; color: var(--text); box-shadow: 0 4px 12px var(--shadow);
  display: flex; align-items: center; gap: 8px;
  transform: translateY(-12px); opacity: 0; transition: all 0.25s ease; pointer-events: none;
}
#notif-toast.show { transform: translateY(0); opacity: 1; }

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-cell { min-width: 0; }
.cal-grid-head { margin-bottom: 6px; }
.cal-head-cell { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 4px 0; }
.cal-cell { min-height: 90px; border: 1px solid var(--border); border-radius: 6px; padding: 6px; background: var(--surface-alt); }
.cal-cell.cal-empty { background: transparent; border: none; }
.cal-cell.cal-today { border-color: var(--brand); border-width: 2px; }
.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.cal-tasks { display: flex; flex-direction: column; gap: 3px; }
.cal-task-chip { font-size: 10px; padding: 2px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* ---------- Webixa branding ---------- */
.brand-wide { display: block; height: auto; max-width: 100%; }
.login-brand .brand-wide { width: 190px; }
.sidebar-brand { flex-direction: column; align-items: flex-start; gap: 4px; padding: 4px 0 0; }
.sidebar-brand .brand-wide { width: 176px; margin-left: -2px; }
.sidebar-brand .brand-sub { font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,0.55); padding-left: 2px; }
.dev-credit { text-align: center; font-size: 12px; font-weight: 700; margin: 0; }
.dev-credit a { color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor; }
.dev-credit a:hover { color: var(--accent-cyan); }
.sidebar-credit { color: rgba(255,255,255,0.55); font-size: 11px; }
.login-credit { color: rgba(255,255,255,0.7); margin-top: 22px; }

input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand) !important; }
.btn-primary, .btn-blue { box-shadow: 0 1px 2px rgba(79,70,229,0.35); }

/* ---------- Public demo box (sign-in page) ---------- */
.demo-card {
  width: 100%; max-width: 380px; margin-top: 16px; border-radius: 10px; padding: 16px 18px 14px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.22); color: #fff;
  backdrop-filter: blur(6px);
}
.demo-card h2 { margin: 0 0 2px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.demo-card h2 .live { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: var(--accent-cyan); color: #0b0a3a; }
.demo-card p { margin: 0 0 10px; font-size: 12px; color: rgba(255,255,255,0.75); }
.demo-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; margin-top: 6px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07); color: #fff; font-size: 12px;
}
.demo-row:hover { background: rgba(255,255,255,0.16); border-color: var(--accent-cyan); }
.demo-row .who b { display: block; font-size: 13px; }
.demo-row .who span { color: rgba(255,255,255,0.72); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; word-break: break-all; }
.demo-row .go { flex: 0 0 auto; font-weight: 700; font-size: 11px; padding: 5px 10px; border-radius: 6px; background: #fff; color: #1D1C56; }
.demo-note { margin-top: 10px; font-size: 11px; color: rgba(255,255,255,0.6); }
