:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e3e8ef;
    --border-strong: #cfd6de;
    --text: #172033;
    --muted: #667085;
    --primary: #ff5c35;
    --primary-dark: #e94d28;
    --nav: #19243a;
    --nav-soft: #25324a;
    --success: #17845a;
    --warning: #b66c00;
    --danger: #c33c4a;

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-lg: 17px;
    --font-size-xl: 28px;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;

    --sidebar-width: 248px;
    --topbar-height: 64px;
    --footer-height: 40px;
    --page-padding-x: 22px;
    --page-padding-y: 20px;
    --control-height: 38px;

    --radius-sm: 7px;
    --radius-md: 9px;
    --radius-lg: 12px;
    --shadow: 0 2px 12px rgba(22, 32, 51, .06);
    --focus-ring: 0 0 0 3px rgba(255, 92, 53, .14);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-regular);
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img, svg, video, canvas, iframe { display: block; max-width: 100%; }
button { color: inherit; }

.app-shell {
    width: 100%;
    height: 100dvh;
    min-height: 100vh;
    overflow: hidden;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: var(--sidebar-width);
    height: 100dvh;
    min-height: 100vh;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    color: #fff;
    background: var(--nav);
}

.brand {
    min-height: 72px;
    margin-bottom: 10px;
    padding: 2px 8px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    object-fit: contain;
}

.sidebar .brand-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
    line-height: 1.15;
}

.sidebar .brand-copy strong {
    color: inherit;
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    letter-spacing: -.02em;
}

.sidebar .brand-copy small {
    color: #9aa6b8;
    font-size: 9px;
    font-weight: var(--font-weight-medium);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sidebar-nav { display: grid; gap: 5px; }
.nav-item {
    min-height: 42px;
    padding: 0 11px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-radius: 9px;
    color: #c6ceda;
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    transition: background-color .15s ease, color .15s ease;
}
.nav-item:hover, .nav-item.active { color: #fff; background: var(--nav-soft); }
.nav-item.active { box-shadow: inset 3px 0 0 var(--primary); }
.nav-icon {
    width: 22px;
    min-width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}
.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; }
.sidebar-user {
    min-width: 0;
    padding: 11px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-top: 1px solid rgba(255,255,255,.1);
}
.avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #33435f;
    font-size: 12px;
    font-weight: var(--font-weight-semibold);
}
.sidebar-user-copy { min-width: 0; flex: 1; display: grid; }
.sidebar-user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: var(--font-weight-semibold); }
.sidebar-user-copy small { margin-top: 2px; color: #9eabc0; font-size: 10px; }
.logout-link { color: #aeb8c8; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    border: 0;
    background: rgba(15, 23, 42, .46);
}

.main-content {
    position: fixed;
    inset: 0 0 0 var(--sidebar-width);
    min-width: 0;
    height: 100dvh;
    min-height: 100vh;
    display: grid;
    grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--footer-height);
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 30;
    width: 100%;
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 var(--page-padding-x);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(255,255,255,.98);
    border-bottom: 1px solid var(--border);
}

.page-scroll {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
}

.app-footer {
    width: 100%;
    height: var(--footer-height);
    min-height: var(--footer-height);
    padding: 0 var(--page-padding-x);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: var(--font-size-xs);
}

.global-search {
    width: min(560px, 58vw);
    min-width: 0;
    height: var(--control-height);
    padding: 0 11px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
}
.global-search:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.global-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
kbd { padding: 3px 6px; border: 1px solid #d7dde6; border-bottom-width: 2px; border-radius: 5px; background: white; color: var(--muted); font-size: 10px; }
.topbar-actions, .heading-actions { display: flex; align-items: center; gap: 9px; }
.icon-button {
    width: var(--control-height);
    height: var(--control-height);
    flex: 0 0 var(--control-height);
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
}
.icon-button:hover { background: var(--surface-soft); }
.mobile-menu { display: none; }

.page-content {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: var(--page-padding-y) var(--page-padding-x) 24px;
}

.page-heading {
    min-height: 56px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}
.page-heading > * { min-width: 0; }
.page-heading h1 { margin: 4px 0; font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); line-height: 1.15; letter-spacing: -.02em; }
.page-heading h2 { font-weight: var(--font-weight-semibold); }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { display: block; margin-bottom: 2px; color: var(--primary); font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); letter-spacing: .08em; text-transform: uppercase; }

.panel, .card, .stat-card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.panel { padding: 16px; }
.panel-header { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-header h2 { margin: 3px 0 0; font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); }

.btn {
    min-height: var(--control-height);
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.btn-primary { color: white; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { color: var(--text); background: white; border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.btn-danger { color: white; background: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .icon-button:focus-visible, a:focus-visible { outline: 3px solid rgba(255,92,53,.2); outline-offset: 2px; }

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
select,
textarea {
    max-width: 100%;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    outline: none;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), select { min-height: var(--control-height); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
label > span, .field-label { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); }

.alert { margin-bottom: 14px; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--radius-md); font-size: 13px; line-height: 1.5; }
.alert-success { color: #067647; background: #ecfdf3; border-color: #abefc6; }
.alert-error { color: #9c2936; background: #fff0f2; border-color: #ffd4d9; }
.alert-warning { color: #92400e; background: #fffbeb; border-color: #fde68a; }

.table-scroll, .table-wrap, .users-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { max-width: 100%; }
th, td { line-height: 1.4; }

.stats-grid { margin-bottom: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 16px; }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: var(--font-weight-medium); }
.stat-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: #fff0ec; }
.stat-card > strong { display: block; margin: 12px 0 3px; font-size: 24px; font-weight: var(--font-weight-semibold); letter-spacing: -.02em; }
.stat-card small { color: var(--muted); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(290px, .75fr); gap: 16px; }
.select-input { min-height: 36px; padding: 0 10px; }
.empty-chart { min-height: 250px; display: flex; flex-direction: column; justify-content: flex-end; }
.chart-bars { height: 210px; padding: 14px 12px 0; display: flex; align-items: flex-end; gap: clamp(10px, 3vw, 30px); border-bottom: 1px solid var(--border); background: repeating-linear-gradient(to bottom, transparent 0, transparent 51px, #eef1f5 52px); }
.chart-bars span { flex: 1; min-width: 16px; max-width: 52px; border-radius: 7px 7px 0 0; background: linear-gradient(to top, #ff6d49, #ffb19f); }
.chart-labels { padding: 10px 4px 0; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.tasks-panel { grid-column: 2; grid-row: 1 / span 2; }
.activity-panel, .quick-actions-panel { min-height: 290px; }
.count-badge { padding: 5px 8px; border-radius: 999px; color: var(--warning); background: #fff4df; font-size: 10px; font-weight: var(--font-weight-semibold); }
.list-stack, .timeline { display: grid; }
.task-row { padding: 12px 0; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); }
.task-check { width: 18px; height: 18px; border: 2px solid #cdd5df; border-radius: 5px; }
.task-copy { min-width: 0; flex: 1; display: grid; }
.task-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: var(--font-weight-medium); }
.task-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.priority { padding: 4px 7px; border-radius: 999px; background: #eef2f7; color: var(--muted); font-size: 10px; font-weight: var(--font-weight-semibold); }
.priority.high { color: var(--danger); background: #fff0f2; }
.priority.medium { color: var(--warning); background: #fff4df; }
.priority.low { color: var(--success); background: #eaf8f2; }
.panel-link { margin-top: 12px; padding: 0; border: 0; background: transparent; color: var(--primary); font-weight: var(--font-weight-semibold); cursor: pointer; }
.timeline { gap: 2px; }
.timeline-row { position: relative; padding: 3px 0 15px 25px; }
.timeline-row::before { content: ""; position: absolute; left: 6px; top: 15px; bottom: -3px; width: 1px; background: var(--border); }
.timeline-row:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 1px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px #fff0ec; }
.timeline-row strong { font-size: 12px; font-weight: var(--font-weight-medium); }
.timeline-row p { margin: 4px 0; color: var(--muted); font-size: 12px; }
.timeline-row small { color: #98a1af; font-size: 10px; }
.empty-state { min-height: 140px; display: grid; place-content: center; gap: 6px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); font-weight: var(--font-weight-semibold); }
.quick-actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.quick-actions-grid button, .quick-actions-grid a { min-height: 96px; padding: 14px; display: grid; justify-items: start; gap: 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); color: var(--text); cursor: pointer; text-align: left; }
.quick-actions-grid button:hover, .quick-actions-grid a:hover { border-color: #ffb6a4; background: #fff8f6; }
.quick-actions-grid button > span { color: var(--primary); font-size: 18px; }
.quick-actions-grid small { color: var(--muted); }

.auth-page { min-height: 100dvh; overflow-y: auto; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #fff0ec 0, transparent 38%), var(--bg); }
.auth-shell { width: min(100%, 900px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: center; gap: 56px; }
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
}
.auth-brand .brand-mark { width: 58px; height: 58px; font-size: 23px; border-radius: 15px; }
.auth-brand h1 { margin: 2px 0 8px; font-size: 38px; font-weight: var(--font-weight-semibold); letter-spacing: -.03em; }
.auth-brand p { max-width: 420px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.auth-card { padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.auth-card-head h2 { margin: 6px 0; font-size: 23px; font-weight: var(--font-weight-semibold); }
.auth-card-head p { margin: 0 0 22px; color: var(--muted); }
.field-label { display: block; margin-bottom: 6px; }
.field-input { width: 100%; height: 42px; margin-bottom: 15px; padding: 0 11px; }

@media (max-width: 1100px) {
    :root { --page-padding-x: 18px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .tasks-panel { grid-column: auto; grid-row: auto; }
}

@media (max-width: 780px) {
    :root {
        --topbar-height: 58px;
        --page-padding-x: 13px;
        --page-padding-y: 14px;
        --font-size-base: 13px;
        --font-size-xl: 24px;
    }

    .sidebar {
        width: min(286px, 86vw);
        transform: translateX(-101%);
        box-shadow: 18px 0 42px rgba(15,23,42,.2);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main-content { inset: 0; }
    .mobile-menu { display: inline-grid; }
    .topbar { padding: 0 var(--page-padding-x); gap: 9px; }
    .global-search { width: auto; flex: 1; }
    .global-search kbd { display: none; }
    .topbar-actions .icon-button { display: none; }
    .app-footer { padding: 0 var(--page-padding-x); }
    .page-heading { min-height: 0; align-items: stretch; flex-direction: column; }
    .heading-actions { width: 100%; flex-wrap: wrap; }
    .heading-actions .btn { flex: 1 1 auto; }
    .stats-grid { grid-template-columns: 1fr; }
    .auth-shell { grid-template-columns: 1fr; gap: 26px; }
    .auth-brand { display: none; }
}

@media (max-width: 480px) {
    :root { --control-height: 40px; }
    .global-search { padding: 0 9px; }
    .panel, .card { padding: 13px; }
    .quick-actions-grid { grid-template-columns: 1fr; }
    .auth-page { padding: 14px; }
    .auth-card { padding: 22px 18px; }
}

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


.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
