/* ============================================================
   ProjectFlow — "Control Tower" Design System (v3)
   A console-grade visual identity for teams shipping software:
   graphite command rail, signal-blue actions, monospace data,
   and a "status rail" language (colored edge + tracked label)
   that unifies badges, cards, columns and nav state.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
    /* ---- surfaces ---- */
    --bg: #eef0f4;
    --bg-elevated: #ffffff;
    --bg-soft: #f4f5f8;
    --bg-sidebar: #10141c;
    --bg-sidebar-raised: #171c26;

    /* ---- sidebar ---- */
    --sidebar-text: #8892a4;
    --sidebar-text-dim: #545c6c;
    --sidebar-heading: #ffffff;
    --sidebar-active-text: #ffffff;
    --sidebar-active-bg: #1b2130;
    --sidebar-hover-bg: #161b26;
    --sidebar-border: #232a38;

    /* ---- ink ---- */
    --text: #12151c;
    --text-muted: #656d7c;
    --border: #dfe3ea;
    --border-soft: #e9ebf0;

    /* ---- signal colors ---- */
    --primary: #3358ec;
    --primary-2: #2544c4;
    --primary-hover: #2947d6;
    --primary-soft: #e7ecfe;
    --accent: #c67d17;
    --accent-soft: #fbeed9;
    --coral: #e6952e;
    --coral-soft: #fbedd9;
    --purple: #7c5cf0;
    --purple-soft: #ece7fc;

    --success: #10855a;
    --success-soft: #dcf3e8;
    --warning: #b9791a;
    --warning-soft: #faedd7;
    --danger: #d13a53;
    --danger-soft: #fbe2e6;
    --info: #2470b8;
    --info-soft: #e2eefb;

    --radius: 9px;
    --radius-lg: 11px;
    --radius-xl: 14px;
    --shadow: 0 1px 2px rgba(16,20,30,.05), 0 1px 1px rgba(16,20,30,.04);
    --shadow-lg: 0 14px 32px -12px rgba(16,20,30,.18), 0 2px 8px rgba(16,20,30,.06);
    --shadow-glow: 0 1px 2px rgba(16,20,30,.08);
    --sidebar-w: 254px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 62px;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-head: 'Space Grotesk', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
    --bg: #0b0d13;
    --bg-elevated: #131722;
    --bg-soft: #1a1f2b;
    --bg-sidebar: #0b0d13;
    --bg-sidebar-raised: #131722;

    --sidebar-text: #8892a6;
    --sidebar-text-dim: #4d5566;
    --sidebar-heading: #f4f5f9;
    --sidebar-active-text: #ffffff;
    --sidebar-active-bg: #1c2436;
    --sidebar-hover-bg: #141926;
    --sidebar-border: #1c212d;

    --text: #eceef3;
    --text-muted: #8892a3;
    --border: #232838;
    --border-soft: #1c2029;

    --primary: #4f6df0;
    --primary-2: #7a97ff;
    --primary-hover: #6280ff;
    --primary-soft: #1a2140;
    --accent: #e3a13f;
    --accent-soft: #34260f;
    --coral: #e6a34a;
    --coral-soft: #33270f;
    --purple: #8b6ff2;
    --purple-soft: #241f42;

    --success: #2fd487;
    --success-soft: #0f2e21;
    --warning: #f0a63c;
    --warning-soft: #332510;
    --danger: #f2607a;
    --danger-soft: #3a1720;
    --info: #4f6df0;
    --info-soft: #10293b;

    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 20px 44px -12px rgba(0,0,0,.55), 0 2px 10px rgba(0,0,0,.3);
    --shadow-glow: 0 1px 2px rgba(0,0,0,.4);
}
[data-theme="dark"] .card, [data-theme="dark"] .kpi-card, [data-theme="dark"] .mini-cal,
[data-theme="dark"] .project-mini-card, [data-theme="dark"] .kanban-col, [data-theme="dark"] .auth-card {
    background: linear-gradient(180deg, #141826, #121521);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scrollbar-width: thin; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    transition: background .2s ease, color .2s ease;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; font-family: var(--font-head); color: var(--text); }
p { margin: 0 0 .8em; color: var(--text-muted); }
ul { list-style: none; margin: 0; padding: 0; }
code, .mono { font-family: var(--font-mono); }
::selection { background: var(--primary); color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { border-color: var(--bg); }

/* ============================================================
   Top progress loader (page-transition feedback)
   ============================================================ */
#topLoader {
    position: fixed; top: 0; left: 0; height: 2.5px; width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 999; transition: width .3s ease, opacity .3s ease;
    box-shadow: 0 0 8px var(--primary);
}
#topLoader.done { opacity: 0; }

/* ============================================================
   Layout shell + command rail sidebar
   ============================================================ */
.app-shell { min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 300;
    transition: transform .3s cubic-bezier(.4,0,.2,1), width .3s cubic-bezier(.4,0,.2,1), background .2s ease;
    border-right: 1px solid var(--sidebar-border);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 4px; }

body.sidebar-hidden .sidebar { transform: translateX(calc(-1 * var(--sidebar-w) - 24px)); }

/* Collapsed = icon rail. Desktop only; toggled with the same button. */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .nav-label,
body.sidebar-collapsed .sidebar .sidebar-section-label span,
body.sidebar-collapsed .sidebar .sidebar-footer .who,
body.sidebar-collapsed .sidebar .sidebar-brand .brand-name { display: none; }
body.sidebar-collapsed .sidebar .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar nav a { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar nav a:hover { padding-left: 0; }
body.sidebar-collapsed .sidebar-section-label { text-align: center; }
body.sidebar-collapsed .sidebar-footer { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

/* Hover-to-preview: on a collapsed desktop rail, hovering the sidebar
   temporarily expands it so labels are reachable without a click. */
@media (min-width: 901px) {
    body.sidebar-collapsed .sidebar:hover {
        width: var(--sidebar-w);
        box-shadow: 18px 0 40px -12px rgba(0,0,0,.35);
    }
    body.sidebar-collapsed .sidebar:hover .nav-label,
    body.sidebar-collapsed .sidebar:hover .sidebar-section-label span,
    body.sidebar-collapsed .sidebar:hover .sidebar-footer .who,
    body.sidebar-collapsed .sidebar:hover .sidebar-brand .brand-name { display: inline; }
    body.sidebar-collapsed .sidebar:hover .sidebar-brand { justify-content: flex-start; padding-left: 22px; }
    body.sidebar-collapsed .sidebar:hover nav a { justify-content: flex-start; padding-left: 14px; }
    body.sidebar-collapsed .sidebar:hover .sidebar-footer { justify-content: flex-start; padding-left: 22px; }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 22px 16px;
    font-weight: 700;
    font-size: 16.5px;
    font-family: var(--font-head);
    color: var(--sidebar-heading);
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 6px;
    white-space: nowrap;
}
.sidebar-brand .logo-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-style: normal; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(51,88,236,.18);
}
.sidebar-section-label {
    font-size: 10px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--sidebar-text-dim);
    padding: 18px 22px 8px;
    white-space: nowrap;
}
.sidebar nav { padding: 0 10px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin: 1px 0;
    border-radius: 7px;
    color: var(--sidebar-text);
    font-size: 13.3px;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    border-left: 2px solid transparent;
    transition: background .15s ease, color .15s ease;
}
.sidebar nav a:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-heading); }
.sidebar nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    border-left-color: var(--primary);
}
.sidebar nav a .ic { width: 18px; text-align: center; opacity: .9; font-size: 14.5px; flex-shrink: 0; }
.sidebar-footer {
    margin-top: auto;
    padding: 16px 22px 18px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 11.5px;
    color: var(--sidebar-text-dim);
    display: flex; align-items: center; gap: 10px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(6,8,13,.55);
    backdrop-filter: blur(2px);
    z-index: 250;
}
body.sidebar-open-mobile .sidebar-backdrop { display: block; }

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
}
body.sidebar-hidden .main { margin-left: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 120;
    height: var(--topbar-h);
}
.topbar-title { font-size: 15.5px; font-weight: 600; font-family: var(--font-head); letter-spacing: -.005em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-new-btn { height: 36px; }

.sidebar-toggle-btn {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s ease, border-color .15s ease;
}
.sidebar-toggle-btn:hover { background: var(--bg-soft); border-color: var(--primary); }
.sidebar-toggle-btn span {
    display: block; width: 15px; height: 1.5px; border-radius: 2px;
    background: var(--text); transition: transform .2s ease, opacity .2s ease, width .2s ease;
}
.sidebar-toggle-btn:hover span { background: var(--primary); }

.icon-btn {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-muted);
    position: relative;
    font-size: 14px;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.badge-dot {
    position: absolute; top: -5px; right: -5px;
    background: var(--danger);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 9.5px; min-width: 16px; height: 16px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; font-weight: 700;
    box-shadow: 0 0 0 2px var(--bg-elevated);
}

.avatar {
    width: 33px; height: 33px; border-radius: 8px;
    background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12.5px; flex-shrink: 0;
    font-family: var(--font-head);
}

.content { padding: 24px 26px 44px; flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; animation: contentIn .35s ease both; }
@keyframes contentIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Page header (used by manage/list pages: title + "+ Add" action)
   ============================================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-header h1 { font-size: 19.5px; margin: 0; }
.page-header p.page-subtitle { margin: 4px 0 0; font-size: 12.8px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { margin: 0; font-size: 14px; }

/* ============================================================
   Stat cards — square icon chip, mono numerals, top status rail
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: cardIn .4s ease forwards;
}
.stat-card .stat-icon {
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; margin-bottom: 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
}
.stat-card .stat-value { font-size: 25px; font-weight: 700; line-height: 1; margin-bottom: 5px; font-family: var(--font-mono); letter-spacing: -.02em; }
.stat-card .stat-label { color: var(--text-muted); font-size: 12px; font-weight: 500; }

/* ============================================================
   Dashboard hero + KPI cards
   ============================================================ */
.dash-hero {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.dash-hero h1 { font-size: 21px; margin: 0 0 4px; }
.dash-hero p { margin: 0; font-size: 13px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.kpi-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 17px 19px;
    box-shadow: var(--shadow);
    opacity: 0;
    animation: cardIn .4s ease forwards;
}
.kpi-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.kpi-card-top .kpi-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding-top: 6px; }
.kpi-card-top .kpi-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.kpi-icon.icon-blue   { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.icon-green  { background: var(--success-soft); color: var(--success); }
.kpi-icon.icon-purple { background: var(--purple-soft); color: var(--purple); }
.kpi-icon.icon-orange { background: var(--accent-soft); color: var(--accent); }
.kpi-card-bottom { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.kpi-value { font-size: 30px; font-weight: 700; font-family: var(--font-head); line-height: 1; letter-spacing: -.02em; }
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.flat { color: var(--text-muted); }

@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.stats-grid .stat-card:nth-child(1), .kpi-grid .kpi-card:nth-child(1) { animation-delay: .02s; }
.stats-grid .stat-card:nth-child(2), .kpi-grid .kpi-card:nth-child(2) { animation-delay: .07s; }
.stats-grid .stat-card:nth-child(3), .kpi-grid .kpi-card:nth-child(3) { animation-delay: .12s; }
.stats-grid .stat-card:nth-child(4), .kpi-grid .kpi-card:nth-child(4) { animation-delay: .17s; }
.stats-grid .stat-card:nth-child(5), .kpi-grid .kpi-card:nth-child(5) { animation-delay: .22s; }

/* ============================================================
   Dashboard: My Projects mini cards + Schedule widget
   ============================================================ */
.dash-row { display: grid; grid-template-columns: 1fr 336px; gap: 16px; margin-bottom: 18px; align-items: start; }
.dash-row-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dash-row-title h3 { margin: 0; font-size: 14px; }
.dash-row-title a { font-size: 12px; color: var(--primary); font-weight: 600; }
.project-mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.project-mini-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 17px 19px; box-shadow: var(--shadow); display: block; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.project-mini-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.project-mini-card p { font-size: 12.5px; min-height: 34px; overflow: hidden; margin-bottom: 14px; }
.project-mini-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { width: 24px; height: 24px; font-size: 10px; border-radius: 50%; margin-left: -7px; box-shadow: 0 0 0 2px var(--bg-elevated); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.mini-due { font-size: 11.3px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; font-family: var(--font-mono); }

/* ---------------- Mini calendar ---------------- */
.mini-cal { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 17px 17px 6px; }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mini-cal-head strong { font-size: 13px; font-family: var(--font-head); }
.mini-cal-nav { display: flex; gap: 6px; color: var(--text-muted); font-size: 12px; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.mini-cal-grid span { font-size: 10px; font-weight: 700; color: var(--text-muted); padding-bottom: 6px; font-family: var(--font-mono); }
.mini-cal-grid .cal-day { font-size: 11.5px; padding: 6px 0; border-radius: 6px; color: var(--text); font-family: var(--font-mono); }
.mini-cal-grid .cal-day.other-month { color: var(--text-muted); opacity: .3; }
.mini-cal-grid .cal-day.today { background: var(--primary); color: #fff; font-weight: 700; }
.mini-cal-grid .cal-day.has-event:not(.today) { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.mini-cal-upcoming { border-top: 1px solid var(--border); margin: 14px -17px 0; padding: 14px 17px 16px; }
.mini-cal-upcoming-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 10px; font-family: var(--font-mono); }
.mini-cal-item { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); border-left: 2px solid var(--border); margin-bottom: 8px; }
.mini-cal-item:last-child { margin-bottom: 0; }
.mini-cal-item.is-next { border-left-color: var(--danger); background: var(--danger-soft); }
.mini-cal-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-cal-item-top strong { font-size: 12px; font-weight: 600; }
.mini-cal-item-top span { font-size: 10.5px; font-weight: 700; color: var(--text-muted); white-space: nowrap; font-family: var(--font-mono); }
.mini-cal-item.is-next .mini-cal-item-top span { color: var(--danger); }
.mini-cal-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   Buttons — flat, rectangular, deliberate. Ripple-ready.
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s ease;
    font-family: var(--font-body);
    position: relative;
    overflow: hidden;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-accent { background: var(--accent-soft); color: var(--accent); }
.btn-accent:hover { background: var(--accent); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.5); transform: scale(0); animation: rippleFx .55s ease-out; pointer-events: none; }
.btn-outline .btn-ripple, .btn-accent .btn-ripple, .btn-danger .btn-ripple { background: rgba(51,88,236,.18); }
@keyframes rippleFx { to { transform: scale(2.6); opacity: 0; } }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=datetime-local], input[type=time], input[type=file], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    background: var(--bg-elevated);
}
textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.form-card-title .form-icon {
    width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}

/* ============================================================
   Table
   ============================================================ */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-family: var(--font-mono); background: var(--bg-soft); }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tr:hover td { background: var(--bg-soft); }

/* ============================================================
   Badges — status rail: rectangular chip, colored left edge,
   tracked uppercase mono label (the signature motif).
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px 3px 8px; border-radius: 5px;
    font-size: 10.5px; font-weight: 700;
    font-family: var(--font-mono);
    text-transform: uppercase; letter-spacing: .04em;
    border-left: 2.5px solid currentColor;
}
.badge-low { background: var(--info-soft); color: var(--info); }
.badge-medium { background: var(--warning-soft); color: var(--warning); }
.badge-high { background: #fde4d0; color: #a4560e; }
[data-theme="dark"] .badge-high { background: #33220f; color: #f0a35f; }
.badge-critical { background: var(--danger-soft); color: var(--danger); }
.badge-todo { background: var(--bg-soft); color: var(--text-muted); border-left-color: var(--text-muted); }
.badge-progress { background: var(--primary-soft); color: var(--primary); }
.badge-review { background: var(--warning-soft); color: var(--warning); }
.badge-testing { background: var(--info-soft); color: var(--info); }
.badge-done { background: var(--success-soft); color: var(--success); }
.badge-hold { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   Alerts / Toasts
   ============================================================ */
.alert { padding: 12px 16px; border-radius: 9px; margin-bottom: 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent; border-left: 3px solid currentColor; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }

#toastStack {
    position: fixed; top: 18px; right: 18px; z-index: 800;
    display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 32px));
}
#toastStack .alert {
    margin-bottom: 0;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    border-left: 3px solid currentColor;
    animation: toastIn .3s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
.alert.toast-out { opacity: 0; transform: translateX(24px); transition: all .3s ease; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    background-image:
        linear-gradient(var(--border-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
    background-size: 42px 42px;
    padding: 20px;
}
.auth-card { width: 100%; max-width: 404px; background: var(--bg-elevated); border: 1px solid var(--border); border-top: 3px solid var(--primary); border-radius: var(--radius-xl); padding: 34px 32px; box-shadow: var(--shadow-lg); }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 700; font-size: 18px; font-family: var(--font-head); }
.auth-logo .logo-dot {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    position: relative;
}
.auth-logo .logo-dot::after { content: '\25A0'; color: #fff; font-size: 11px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 12.5px; color: var(--text-muted); }

/* ============================================================
   Kanban
   ============================================================ */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { flex: 0 0 280px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 230px); overflow: hidden; }
.kanban-col-header { padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 12.5px; position: relative; font-family: var(--font-head); }
.kanban-col-header::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.kanban-col[data-status="Done"] .kanban-col-header::before { background: var(--success); }
.kanban-col[data-status="In Progress"] .kanban-col-header::before { background: var(--info); }
.kanban-col[data-status="Review"] .kanban-col-header::before { background: var(--warning); }
.kanban-col-count { background: var(--bg-soft); border-radius: 5px; padding: 2px 9px; font-size: 11px; color: var(--text-muted); font-weight: 700; font-family: var(--font-mono); }
.kanban-col-body { padding: 10px; flex: 1; overflow-y: auto; min-height: 60px; }
.kanban-card {
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 9px;
    padding: 12px 13px; margin-bottom: 9px; cursor: grab; font-size: 12.8px;
    transition: box-shadow .15s ease, transform .12s ease, border-color .15s ease;
    box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: var(--shadow-lg); border-color: var(--primary); transform: translateY(-2px); }
.kanban-card.dragging { opacity: .4; }
.kanban-col-body.drag-over { background: var(--primary-soft); border-radius: 8px; }
.kanban-card-title { font-weight: 600; margin-bottom: 9px; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ============================================================
   Misc utilities
   ============================================================ */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; } .mb-22 { margin-bottom: 22px; }
.text-muted { color: var(--text-muted); }
.progress-bar { height: 7px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .5s cubic-bezier(.4,0,.2,1); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.dropdown-menu {
    position: absolute; right: 0; top: 46px; min-width: 264px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 150; display: none; overflow: hidden;
}
.dropdown-menu.open { display: block; animation: dropIn .16s cubic-bezier(.2,.9,.3,1.2); }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.dropdown-item { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-soft); }
a.dropdown-item { display: flex; align-items: center; gap: 9px; }
a.dropdown-item .ic-svg { flex-shrink: 0; margin-right: 0; vertical-align: initial; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 16px; }
.back-link:hover { color: var(--primary); }

/* ============================================================
   Dashboard v2 — hero utility bar, chart row, list rows,
   team performance strip, right rail (events/calendar/activity)
   ============================================================ */
.hero-period-select {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 13px; font-size: 12.5px; font-weight: 600;
    color: var(--text); cursor: pointer;
}
.hero-period-select .ic-svg { width: 13px; height: 13px; color: var(--text-muted); }
.hero-period-select select {
    border: none; background: transparent; padding: 0; margin: 0; width: auto;
    font: inherit; font-weight: 600; color: inherit; cursor: pointer; appearance: none;
    -webkit-appearance: none; -moz-appearance: none;
}
.hero-period-select select:focus { outline: none; box-shadow: none; }
.dash-filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-filter-reset { margin-left: auto; color: var(--text-muted); }
.full-cal-nav a { text-decoration: none; }

.dash-main-grid { display: grid; grid-template-columns: 1fr 336px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .dash-main-grid { grid-template-columns: 1fr; } }

.chart-row { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-bottom: 18px; }
@media (max-width: 720px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow); }
.chart-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.chart-card-head h3 { margin: 0 0 2px; font-size: 14.5px; }
.chart-card-head p { margin: 0; font-size: 12px; }
.chart-wrap { position: relative; margin-top: 6px; }
.chart-bubble {
    position: absolute; transform: translate(-50%, -128%);
    background: var(--text); color: var(--bg-elevated);
    font-family: var(--font-mono); font-weight: 700; font-size: 11.5px;
    padding: 4px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none;
}
[data-theme="dark"] .chart-bubble { background: #f3f5fa; color: #12151d; }
.chart-bubble::after {
    content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--text);
}
[data-theme="dark"] .chart-bubble::after { border-top-color: #f3f5fa; }
.chart-axis-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); }

.donut-wrap { display: flex; align-items: center; gap: 18px; margin-top: 8px; }
.donut-center-label { font-family: var(--font-head); }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.donut-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.donut-legend-row .dl-left { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.donut-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-row .dl-pct { font-weight: 700; color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }

.list-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; margin-top: 4px; }
.list-section-title h3 { margin: 0; font-size: 14.5px; }
.list-section-title a { font-size: 12px; color: var(--primary); font-weight: 600; }
.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .split-row { grid-template-columns: 1fr; } }

.row-list { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 13px; padding: 14px 17px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: none; }
.row-icon { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: #fff; }
.row-item-body { flex: 1; min-width: 0; }
.row-item-title { font-size: 13.2px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item-sub { font-size: 11.5px; color: var(--text-muted); }
.row-item-progress { width: 108px; flex-shrink: 0; }
.row-item-progress .progress-bar { margin-bottom: 5px; }
.row-item-pct { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-align: right; font-family: var(--font-mono); }

.task-row-check {
    width: 19px; height: 19px; border-radius: 50%; border: 2px solid var(--border);
    flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px;
}
.task-row-check.is-done { background: var(--success); border-color: var(--success); }
.task-row-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.task-row-project { font-size: 11.5px; color: var(--text-muted); width: 116px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row-due { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); width: 54px; text-align: right; }

.team-perf-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 4px; }
.team-perf-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 15px 17px; box-shadow: var(--shadow); }
.team-perf-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.team-perf-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; }
.team-perf-name { font-size: 12.8px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-perf-role { font-size: 11px; color: var(--text-muted); }
.team-perf-pct { margin-left: auto; font-weight: 700; font-size: 13px; font-family: var(--font-mono); }
.trophy-card {
    background: linear-gradient(135deg, var(--primary-soft), var(--purple-soft));
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 15px 17px; display: flex; align-items: center; gap: 13px;
}
.trophy-emoji { width: 42px; height: 42px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; box-shadow: var(--shadow); }
.trophy-card strong { display: block; font-size: 13px; margin-bottom: 2px; }
.trophy-card span { font-size: 11.5px; color: var(--text-muted); }

/* ---- right rail ---- */
.rail-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 17px; margin-bottom: 16px; }
.rail-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rail-card-head h3 { margin: 0; font-size: 13.5px; }
.rail-card-head a { font-size: 11.5px; color: var(--primary); font-weight: 600; }

.event-item { display: flex; gap: 11px; margin-bottom: 13px; }
.event-item:last-child { margin-bottom: 0; }
.event-date-badge {
    width: 42px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
    text-align: center; border: 1px solid var(--border);
}
.event-date-badge .m { background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; text-transform: uppercase; padding: 2px 0; letter-spacing: .04em; }
.event-date-badge .d { background: var(--bg-soft); font-size: 15px; font-weight: 700; padding: 4px 0; font-family: var(--font-mono); }
.event-item-body { flex: 1; min-width: 0; }
.event-item-title { font-size: 12.3px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.event-item-time { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; align-self: flex-start; margin-top: 1px; }

.full-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.full-cal-head strong { font-size: 13px; font-family: var(--font-head); }
.full-cal-nav { display: flex; gap: 4px; }
.full-cal-nav button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.full-cal-nav .ic-svg { width: 12px; height: 12px; }
.full-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.full-cal-grid span.dow { font-size: 10px; font-weight: 700; color: var(--text-muted); padding-bottom: 8px; font-family: var(--font-mono); }
.full-cal-grid .fcal-day { font-size: 12px; padding: 7px 0; border-radius: 7px; color: var(--text); font-family: var(--font-mono); cursor: default; }
.full-cal-grid .fcal-day.other-month { color: var(--text-muted); opacity: .28; }
.full-cal-grid .fcal-day.today { background: var(--primary); color: #fff; font-weight: 700; }
.full-cal-grid .fcal-day.has-event:not(.today) { box-shadow: inset 0 -2px 0 var(--primary); font-weight: 700; }

.activity-item { display: flex; gap: 11px; margin-bottom: 15px; }
.activity-item:last-child { margin-bottom: 0; }
.activity-ic { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.activity-item-body { flex: 1; min-width: 0; }
.activity-item-text { font-size: 12.3px; line-height: 1.4; }
.activity-item-text strong { font-weight: 700; }
.activity-item-sub { font-size: 11.3px; color: var(--text-muted); margin-top: 1px; }
.activity-item-time { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; font-family: var(--font-mono); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-w) - 24px)); box-shadow: 12px 0 40px rgba(0,0,0,.35); width: var(--sidebar-w) !important; }
    body.sidebar-open-mobile .sidebar { transform: translateX(0); }
    body.sidebar-collapsed .sidebar .nav-label,
    body.sidebar-collapsed .sidebar .sidebar-section-label span,
    body.sidebar-collapsed .sidebar .sidebar-footer .who,
    body.sidebar-collapsed .sidebar .sidebar-brand .brand-name { display: inline; }
    .main { margin-left: 0 !important; }
    .content { padding: 18px 15px 30px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-row { grid-template-columns: 1fr; }
    .topbar { padding: 0 15px; }
    .topbar-title { font-size: 14.5px; }
    #toastStack { left: 12px; right: 12px; width: auto; top: 12px; }
}
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .dash-hero { flex-direction: column; }
    .auth-card { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ============================================================
   Icon set (inline SVG) — replaces emoji glyphs in nav/topbar
   ============================================================ */
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic-svg { display: block; }
.sidebar nav a .ic { width: 18px; height: 18px; color: var(--sidebar-text-dim); transition: color .15s ease; }
.sidebar nav a:hover .ic,
.sidebar nav a.active .ic { color: inherit; }
.icon-btn .ic-svg { width: 17px; height: 17px; }
.dropdown-item .ic-svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }

/* ============================================================
   Toggle switch — replaces raw checkboxes for on/off settings
   ============================================================ */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 23px;
    flex-shrink: 0;
    vertical-align: middle;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    transition: background .2s ease;
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 17px; width: 17px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(17px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }
