:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #d9e2ec;
    --border-strong: #bcccdc;
    --text: #243b53;
    --text-muted: #52606d;
    --heading: #102a43;
    --brand: #0066cc;
    --brand-hover: #0052a3;
    --danger-bg: #fdeaea;
    --danger-border: #ef9a9a;
    --danger-text: #8a1f1f;
    --shadow: 0 10px 30px rgba(16, 42, 67, 0.08);
    --radius: 14px;
    --radius-small: 10px;
    --max-width: 1080px;
    --nav-width: 290px;
    --header-height: 72px;
    --space-1: 0.35rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --font: Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(16, 42, 67, 0.04);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-5);
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--heading);
    font-size: 1.4rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.menu-toggle:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
    text-decoration: none;
}

.site-brand {
    min-width: 0;
}

.site-brand__link {
    color: var(--heading);
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}

.site-brand__link:hover {
    text-decoration: none;
}

.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: min(var(--nav-width), calc(100vw - 2rem));
    height: 100vh;
    padding: calc(var(--header-height) + var(--space-4)) var(--space-4) var(--space-4);
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
}

.site-nav.is-open {
    transform: translateX(0);
}

.site-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(16, 42, 67, 0.38);
}

.page-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-8) var(--space-5) var(--space-10);
}

.page-section {
    display: grid;
    gap: var(--space-6);
}

.page-section h1,
.page-section h2,
.page-section h3,
.auth-card h1,
.card h2,
.card h3 {
    margin: 0;
    color: var(--heading);
    line-height: 1.2;
}

.page-section p,
.card p,
.auth-card p {
    margin: 0;
    color: var(--text);
}

.nav {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    gap: var(--space-5);
}

.nav__section {
    display: grid;
    gap: var(--space-2);
}

.nav__section--bottom {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.nav__label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.nav__link {
    display: block;
    padding: 0.85rem 0.95rem;
    border-radius: 12px;
    color: var(--heading);
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.nav__link:hover {
    background: var(--surface-muted);
    border-color: var(--border);
    text-decoration: none;
}

.nav__link--disabled {
    color: var(--text-muted);
    background: var(--surface-muted);
    border-color: var(--border);
    cursor: default;
}

.nav__link--button {
    width: 100%;
    text-align: left;
    background: none;
    color: var(--heading);
    border: 1px solid transparent;
}

.nav__user {
    padding: 0.25rem 0.2rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    word-break: break-word;
}

.card-grid {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-page {
    min-height: calc(100vh - var(--header-height) - var(--space-10));
    display: grid;
    place-items: start center;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    display: grid;
    gap: var(--space-5);
    padding: var(--space-8);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form {
    display: grid;
    gap: var(--space-5);
}

.form-row,
.form-group {
    display: grid;
    gap: var(--space-2);
}

label {
    color: var(--heading);
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    min-height: 46px;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus,
a:focus {
    outline: 3px solid rgba(0, 102, 204, 0.18);
    outline-offset: 2px;
}

.form-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.button,
button,
input[type="submit"] {
    min-height: 46px;
    padding: 0.8rem 1.15rem;
    border: 1px solid var(--brand);
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    text-decoration: none;
}

.button-secondary {
    background: var(--surface);
    color: var(--heading);
    border-color: var(--border-strong);
}

.button-secondary:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
}

.alert {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
}

.alert-error {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

thead {
    background: var(--surface-muted);
}

th,
td {
    text-align: left;
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--heading);
    font-size: 0.95rem;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}

.stack {
    display: grid;
    gap: var(--space-4);
}

.muted {
    color: var(--text-muted);
}

.inline-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
}

.checkbox-row {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

@media (max-width: 700px) {
    .site-header__inner {
        padding: 0 var(--space-4);
    }

    .page-content {
        padding: var(--space-6) var(--space-4) var(--space-8);
    }

    .auth-card,
    .card {
        padding: var(--space-5);
    }

    th,
    td {
        padding: 0.8rem;
    }
}
.flash-stack {
    display: grid;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.alert-success {
    background: #e8f7ee;
    border-color: #98d5ad;
    color: #1f6b3b;
}

.alert-warning {
    background: #fff6e5;
    border-color: #f0c36d;
    color: #8a5a00;
}

.alert-info {
    background: #eaf3ff;
    border-color: #9fc2f3;
    color: #1f4f8a;
}
/* =========================
   Tool Layout (2-column)
   ========================= */

.tool-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    align-items: start;
}

@media (max-width: 900px) {
    .tool-layout {
        grid-template-columns: 1fr;
    }
}


/* =========================
   Form Styles
   ========================= */

.form {
    display: grid;
    gap: var(--space-4);
}

.form-group {
    display: grid;
    gap: var(--space-2);
}

.form-group label {
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    padding: var(--space-2);
    border: 1px solid #ccc;
    border-radius: var(--radius);
    font-size: 14px;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-actions {
    margin-top: var(--space-2);
}


/* =========================
   Radio Buttons
   ========================= */

.radio-group {
    display: flex;
    gap: var(--space-4);
}

.radio-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}


/* =========================
   History Panel
   ========================= */

.history-card {
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.history-list {
    overflow-y: auto;
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding-right: 4px;
}


/* =========================
   History Item (cards)
   ========================= */

.history-item {
    border: 1px solid #ddd;
    border-radius: var(--radius);
    padding: var(--space-3);
    background: #fafafa;
}

.history-item__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}


/* =========================
   Badges
   ========================= */

.badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #e8f7ee;
    color: #1f6b3b;
}

.badge-danger {
    background: #fdeaea;
    color: #8a1f1f;
}