:root {
    --bg: #f4f1ea;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: #ffffff;
    --text: #1e1d1b;
    --muted: #6f6a60;
    --line: rgba(30, 29, 27, 0.08);
    --accent: #d35400;
    --accent-strong: #a04000;
    --success: #1f8a5b;
    --danger: #c0392b;
    --warning: #e0a106;
    --shadow: 0 20px 45px rgba(39, 31, 24, 0.10);
    --radius: 24px;
    --radius-sm: 16px;
    --sidebar-width: 280px;
}

html[data-theme="dark"] {
    --bg: #171412;
    --panel: rgba(31, 27, 24, 0.92);
    --panel-strong: #221d19;
    --text: #f7f2ec;
    --muted: #b6aa9b;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #ff8c42;
    --accent-strong: #ff6f1f;
    --success: #4fc78b;
    --danger: #ff7767;
    --warning: #f3bc49;
    --shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(211, 84, 0, 0.12), transparent 32%),
        radial-gradient(circle at left bottom, rgba(31, 138, 91, 0.10), transparent 28%),
        var(--bg);
    color: var(--text);
}

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

.hidden {
    display: none !important;
}

.hidden-desktop {
    display: none;
}

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

.sidebar {
    padding: 28px 22px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-mobile-header {
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.mobile-menu-button {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 25;
    border: 0;
    border-radius: 18px;
    width: 52px;
    height: 52px;
    padding: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
}

.menu-icon {
    display: inline-block;
    font-size: 1.65rem;
    line-height: 1;
    font-weight: 700;
}

.close-menu-icon {
    font-size: 1.9rem;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 98;
    background: rgba(17, 13, 10, 0.48);
    backdrop-filter: blur(4px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: var(--muted);
    font-size: 0.9rem;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background-image: url(/assets/img/logo-senna.png);
    color: white;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    font-weight: 700;
    box-shadow: var(--shadow);
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
}

.nav-menu {
    display: grid;
    gap: 10px;
}

.nav-link,
.primary-button,
.outline-button,
.ghost-button,
.danger-button {
    border: 0;
    border-radius: 16px;
    padding: 12px 16px;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.nav-link {
    background: transparent;
    color: var(--text);
    text-align: left;
}

.nav-link.active,
.nav-link:hover {
    background: var(--panel);
    transform: translateX(4px);
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: white;
}

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

.danger-button {
    background: rgba(192, 57, 43, 0.1);
    color: var(--danger);
}

.ghost-button {
    background: transparent;
    color: var(--muted);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
}

.main-content {
    padding: 30px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: start;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: 2rem;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box input,
.modal-form input,
.modal-form select,
.modal-form textarea,
.login-form input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    outline: none;
}

.content-grid {
    display: grid;
    gap: 18px;
}

.dashboard-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

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

.card {
    padding: 22px;
}

.metric-card {
    min-height: 154px;
}

.metric-label {
    color: var(--muted);
    font-size: 0.95rem;
}

.metric-value {
    margin-top: 20px;
    font-size: 2rem;
    font-weight: 700;
}

.metric-note {
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.panel-header {
    padding: 22px 22px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.panel-title {
    margin: 0;
    font-size: 1.1rem;
}

.panel-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.table-wrapper {
    overflow: auto;
    padding: 18px 22px 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
}

.toolbar {
    padding: 0 22px 18px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.toolbar .search-box {
    min-width: 240px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.84rem;
    background: rgba(211, 84, 0, 0.12);
    color: var(--accent-strong);
}

.badge.success {
    background: rgba(31, 138, 91, 0.12);
    color: var(--success);
}

.badge.warning {
    background: rgba(224, 161, 6, 0.15);
    color: var(--warning);
}

.badge.danger {
    background: rgba(192, 57, 43, 0.14);
    color: var(--danger);
}

.action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.small-button {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    border-radius: 12px;
    padding: 8px 10px;
    cursor: pointer;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 40;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 13, 10, 0.55);
}

.modal-panel {
    position: relative;
    width: min(920px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    overflow: auto;
    background: var(--panel-strong);
    border-radius: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.modal-header {
    padding: 22px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-form {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.modal-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.modal-form .full {
    grid-column: 1 / -1;
}

.modal-form textarea {
    min-height: 110px;
    resize: vertical;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.login-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top left, rgba(211, 84, 0, 0.20), transparent 25%),
        radial-gradient(circle at bottom right, rgba(31, 138, 91, 0.16), transparent 28%),
        rgba(14, 12, 10, 0.42);
    backdrop-filter: blur(16px);
    z-index: 50;
}

.login-card {
    width: min(420px, calc(100vw - 28px));
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-brand {
    margin-bottom: 24px;
}

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

.full-width {
    width: 100%;
}

.login-tip {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.timeline-item {
    padding-left: 14px;
    border-left: 2px solid var(--accent);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    padding: 18px 22px 22px;
}

.summary-item {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.38);
}

.summary-item strong,
.summary-item span {
    display: block;
}

.summary-item span {
    color: var(--muted);
    margin-bottom: 8px;
}

.empty-state {
    padding: 34px 22px;
    color: var(--muted);
}

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

    .main-content {
        padding: 30px 30px 30px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(320px, 84vw);
        z-index: 99;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        background: var(--panel-strong);
        overflow: scroll;
    }

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

    .hidden-desktop {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-mobile-header {
        display: flex;
        margin-bottom: -4px;
        position: absolute;
        right: 20px;
    }

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

    .span-3,
    .span-4,
    .span-6,
    .span-8,
    .span-12 {
        grid-column: span 2;
    }
}

@media (max-width: 720px) {
    .main-content {
        padding: 76px 18px 18px;
    }

    .topbar {
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar {
        padding: 0 16px 16px;
    }

    .toolbar .search-box {
        width: 100%;
        min-width: 0;
    }

    .toolbar .action-row {
        width: 100%;
    }

    .toolbar .small-button {
        width: 100%;
    }

    .table-wrapper {
        padding: 14px 16px 18px;
        overflow: visible;
    }

    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody {
        display: grid;
        gap: 14px;
    }

    .responsive-table tr {
        border: 1px solid var(--line);
        border-radius: 20px;
        padding: 6px 0;
        background: var(--panel-strong);
        box-shadow: 0 12px 30px rgba(39, 31, 24, 0.08);
    }

    .responsive-table td {
        border-bottom: 1px solid var(--line);
        padding: 12px 14px;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
    }

    .responsive-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .responsive-table td.actions-cell {
        padding-top: 14px;
    }

    .responsive-table td.actions-cell .action-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .responsive-table td.actions-cell .small-button {
        width: 100%;
    }

    .modal-form {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .span-3,
    .span-4,
    .span-6,
    .span-8,
    .span-12 {
        grid-column: span 1;
    }
}
