:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #eef2f5;
    --text: #17202a;
    --muted: #637083;
    --line: #d9e0e7;
    --primary: #176c72;
    --primary-strong: #0e555a;
    --info: #246b9f;
    --success: #29724a;
    --warning: #9a650c;
    --danger: #a83232;
    --radius: 8px;
    --shadow: 0 10px 24px rgba(27, 39, 51, 0.08);
    --sidebar: 264px;
    font-family: Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

label input,
label select,
label textarea {
    font-weight: 400;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #18212b;
    color: #eef3f7;
    padding: 18px 14px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px 20px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.brand small {
    display: block;
    color: #aeb9c6;
    min-height: 1em;
}

.nav {
    display: grid;
    gap: 4px;
}

.nav a,
.nav-group {
    padding: 10px 12px;
    border-radius: 6px;
    color: #dbe3ea;
}

.nav a:hover,
.nav a.is-active {
    background: #243140;
    text-decoration: none;
}

.nav-group {
    margin-top: 14px;
    color: #93a2b3;
    font-size: 12px;
    text-transform: uppercase;
}

.content-shell {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 22px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.topbar span {
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions,
.hero-actions,
.button-row,
.inline-actions,
.table-actions,
.note-actions,
.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.main-content {
    padding: 22px;
    max-width: 1500px;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f4f6f8 0%, #e9eef2 100%);
}

.auth-main {
    width: min(440px, calc(100vw - 24px));
}

.auth-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card {
    padding: 28px;
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 18px;
}

h3 {
    font-size: 15px;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    background: var(--surface-alt);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    text-decoration: none;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

.button-primary:hover {
    background: var(--primary-strong);
}

.button-secondary {
    background: #e7eef2;
    color: #1b2b36;
    border-color: #cfd9e1;
}

.button-outline {
    background: transparent;
    border-color: var(--line);
}

.button-danger {
    background: var(--danger);
    color: #fff;
}

.button-success {
    background: var(--success);
    color: #fff;
}

.button-link,
.button-link-danger {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
}

.button-link-danger {
    color: var(--danger);
}

.mobile-menu {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.user-chip {
    padding: 7px 10px;
    border-radius: 6px;
    background: var(--surface-alt);
}

.quick-actions,
.stats-grid,
.dashboard-grid,
.summary-grid,
.search-results {
    display: grid;
    gap: 16px;
}

.quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
    margin-bottom: 18px;
}

.stats-grid {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    margin-bottom: 18px;
}

.stat {
    padding: 16px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
}

.stat span {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.stat strong {
    display: block;
    font-size: 28px;
    margin-top: 6px;
}

.stat.danger strong {
    color: var(--danger);
}

.stat.warning strong {
    color: var(--warning);
}

.stat.success strong {
    color: var(--success);
}

.stat.info strong {
    color: var(--info);
}

.dashboard-grid,
.summary-grid,
.search-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid,
.filters {
    display: grid;
    gap: 14px;
}

.form-grid.two,
.filters {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.filters {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
    margin-bottom: 14px;
}

.field-span {
    grid-column: 1 / -1;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.check input {
    width: auto;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) auto;
    gap: 8px;
    margin-bottom: 10px;
}

.flash,
.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
}

.flash-success,
.alert-success {
    background: #e8f4ee;
    color: #195437;
    border-color: #bfe0ce;
}

.flash-danger,
.alert-danger {
    background: #f9e7e7;
    color: #842626;
    border-color: #e4b8b8;
}

.alert-warning {
    background: #fff3d8;
    color: #76500d;
    border-color: #ecd18d;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    background: #f8fafb;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.row-danger {
    background: #fff6f6;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid transparent;
}

.badge-neutral {
    background: #eef2f5;
    color: #394957;
}

.badge-info {
    background: #e2f0f8;
    color: #1b5f8d;
}

.badge-success {
    background: #e6f3ec;
    color: #1d633f;
}

.badge-warning {
    background: #fff0cf;
    color: #7b510a;
}

.badge-danger {
    background: #f8dfdf;
    color: #8f2727;
}

.badge-muted {
    background: #edf0f2;
    color: #697684;
}

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

.progress {
    height: 8px;
    width: 90px;
    border-radius: 999px;
    overflow: hidden;
    background: #dfe6ec;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--primary);
}

.inline-warning {
    margin-left: 8px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 800;
}

.list {
    display: grid;
    gap: 8px;
}

.list.compact {
    gap: 4px;
}

.list-row {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    background: #fff;
}

.list-row:hover {
    border-color: #b8c6d0;
    text-decoration: none;
}

.list-row small,
.empty,
.description,
.note-card small,
.attachment-row small {
    color: var(--muted);
}

.metric-row,
.detail-grid {
    display: grid;
    gap: 8px;
}

.metric-row {
    grid-template-columns: 1fr auto;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
}

.split-lists {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.project-hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 20px;
    border-radius: var(--radius);
    background: #ffffff;
    border: 1px solid var(--line);
    margin-bottom: 18px;
}

.project-hero.is-overdue {
    border-color: #e4b8b8;
    background: #fff7f7;
}

.detail-grid {
    grid-template-columns: 150px 1fr;
    margin-bottom: 14px;
}

.timeline {
    display: grid;
    gap: 14px;
}

.note-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 14px;
    background: #fff;
}

.note-card.is-important {
    border-left-color: var(--danger);
}

.note-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.note-actions form,
.table-actions form,
.attachment-row form {
    display: inline-flex;
}

.note-body {
    margin-top: 12px;
    white-space: normal;
}

.attachments {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.attachment-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
    padding: 9px 10px;
    border-radius: 6px;
    background: #f8fafb;
    border: 1px solid var(--line);
}

.pagination {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.pagination a {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.pagination a.is-active {
    background: var(--primary);
    color: #fff;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-head {
    padding: 10px;
    background: #eef2f5;
    font-weight: 800;
    border-right: 1px solid var(--line);
}

.calendar-day {
    min-height: 128px;
    padding: 8px;
    border-top: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: #fff;
}

.calendar-day.is-outside {
    background: #f6f8fa;
    color: #9aa6b2;
}

.calendar-day.is-today {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.calendar-event {
    display: block;
    margin-top: 5px;
    padding: 4px 6px;
    border-radius: 5px;
    font-size: 12px;
    color: #fff;
    overflow-wrap: anywhere;
}

.event-start {
    background: var(--info);
}

.event-deadline {
    background: var(--danger);
}

.event-complete {
    background: var(--success);
}

.event-reminder {
    background: var(--warning);
}

.search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.danger-zone {
    border-color: #e4b8b8;
}

.debug {
    max-height: 360px;
    overflow: auto;
    padding: 12px;
    background: #111827;
    color: #e5e7eb;
    border-radius: 6px;
}

.upload-feedback {
    margin-top: 8px;
    color: var(--muted);
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .dashboard-grid,
    .summary-grid,
    .search-results {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 40;
        inset: 0 auto 0 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 160ms ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .mobile-menu {
        display: inline-grid;
        place-items: center;
    }

    .topbar {
        align-items: flex-start;
        padding: 10px 12px;
    }

    .topbar-actions {
        justify-content: flex-end;
    }

    .topbar-actions .button-secondary,
    .user-chip {
        display: none;
    }

    .main-content {
        padding: 12px;
    }

    .stats-grid,
    .form-grid.two,
    .filters,
    .split-lists {
        grid-template-columns: 1fr;
    }

    .project-hero,
    .note-head {
        display: grid;
    }

    .inline-form,
    .search-form,
    .attachment-row {
        grid-template-columns: 1fr;
    }

    .calendar-grid {
        display: block;
        border: 0;
    }

    .calendar-head {
        display: none;
    }

    .calendar-day {
        min-height: 88px;
        margin-bottom: 8px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        margin-bottom: 10px;
        background: #fff;
        padding: 8px;
    }

    .data-table td {
        border: 0;
        padding: 6px 4px;
    }
}

