/* ==========================================================================
   App design system — plain, hand-written CSS. No build step, no framework.
   Served directly as a static file; edit and refresh, nothing to compile.
   ========================================================================== */

:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-primary: #4f46e5;
    --color-primary-dark: #4338ca;
    --color-primary-light: #eef2ff;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-success: #059669;
    --color-success-light: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-light: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-light: #fef2f2;
    --border-color: #e5e7eb;
    --radius: 12px;
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

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

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

h1, h2, h3 { margin: 0; }

/* ===== Card ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.card-title {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    margin: 0 0 .75rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border: none;
    border-radius: 8px;
    padding: .55rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.2;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary { background: #f3f4f6; color: var(--color-text); }
.btn-secondary:hover { background: #e5e7eb; text-decoration: none; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .75rem; font-size: .75rem; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border-radius: 999px;
    padding: .15rem .65rem;
    font-size: .75rem;
    font-weight: 500;
}
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-label .optional { font-weight: 400; color: var(--color-text-muted); }
.form-input {
    display: block;
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: .55rem .75rem;
    font-size: .875rem;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}
.form-input:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea.form-input { resize: vertical; }
.form-error { color: var(--color-danger); font-size: .8rem; margin: .35rem 0 0; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--color-text); }
.checkbox-row input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--color-primary); }

/* ===== Alerts / session messages ===== */
.alert { border-radius: 8px; padding: .75rem 1rem; font-size: .875rem; margin-bottom: 1rem; }
.alert-success { background: var(--color-success-light); color: var(--color-success); }
.alert-danger { background: var(--color-danger-light); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning); }

/* ===== Tables ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    text-align: left;
    color: var(--color-text-muted);
    font-weight: 500;
    padding: .5rem 1rem .5rem 0;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table td {
    padding: .6rem 1rem .6rem 0;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table .actions form,
.data-table .actions a,
.data-table .actions button { display: inline-block; }
.data-table .actions > * + * { margin-left: .5rem; }
.table-scroll { overflow-x: auto; }
.table-empty { padding: 1.5rem 0; color: var(--color-text-muted); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state h3 { font-size: .875rem; font-weight: 600; }
.empty-state p { color: var(--color-text-muted); font-size: .875rem; margin: .25rem 0 0; }

/* ===== Guest (auth) layout ===== */
.guest-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
}
.guest-brand { font-size: 1.25rem; font-weight: 600; color: var(--color-text); margin-bottom: 1.5rem; }
.guest-card { width: 100%; max-width: 28rem; }
.guest-heading { font-size: 1.125rem; font-weight: 600; margin-bottom: .25rem; }
.guest-subheading { color: var(--color-text-muted); font-size: .875rem; margin: 0 0 1.5rem; }
.guest-footer { text-align: center; font-size: .875rem; color: var(--color-text-muted); margin-top: 1.5rem; }

/* ===== Dashboard shell ===== */
.shell-topbar-mobile {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-surface);
    border-bottom: 1px solid var(--border-color);
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    font-weight: 600;
}
.shell-topbar-mobile form { margin: 0; }
.shell-topbar-mobile button {
    background: none; border: none; font: inherit; color: var(--color-text-muted); cursor: pointer;
}
.shell-main { padding: 1.5rem 1rem 5.5rem; }
.shell-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 10;
    background: var(--color-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
}
.shell-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .5rem .75rem;
    font-size: .7rem;
    font-weight: 500;
    color: var(--color-text-muted);
}
.shell-bottom-nav-item.is-active { color: var(--color-primary); }
.shell-sidebar { display: none; }
.shell-page-title { font-size: 1.25rem; font-weight: 600; margin: 0 0 1.5rem; }

.icon { width: 20px; height: 20px; flex-shrink: 0; }

@media (min-width: 1024px) {
    .shell { display: flex; }
    .shell-sidebar {
        display: flex;
        flex-direction: column;
        width: 16rem;
        flex-shrink: 0;
        background: var(--color-surface);
        border-right: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        height: 100vh;
    }
    .shell-sidebar-header {
        height: 4rem;
        display: flex;
        align-items: center;
        padding: 0 1.5rem;
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
    }
    .shell-nav { flex: 1; padding: 1rem .75rem; }
    .shell-nav-item {
        display: flex;
        align-items: center;
        gap: .75rem;
        border-radius: 8px;
        padding: .55rem .75rem;
        font-size: .875rem;
        font-weight: 500;
        color: var(--color-text-muted);
        margin-bottom: .15rem;
    }
    .shell-nav-item:hover { background: #f3f4f6; color: var(--color-text); text-decoration: none; }
    .shell-nav-item.is-active { background: var(--color-primary-light); color: var(--color-primary); }
    .shell-sidebar-footer { border-top: 1px solid var(--border-color); padding: 1rem 1.5rem; font-size: .875rem; }
    .shell-sidebar-footer form { margin-top: .5rem; }
    .shell-sidebar-footer button { background: none; border: none; font: inherit; color: var(--color-text-muted); cursor: pointer; padding: 0; }
    .shell-sidebar-footer button:hover { color: var(--color-danger); }
    .shell-content { flex: 1; min-width: 0; }
    .shell-topbar-mobile { display: none; }
    .shell-main { padding: 2rem; }
    .shell-bottom-nav { display: none; }
}

/* ===== Layout helpers (small, named, no utility-framework sprawl) ===== */
.stat-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }

.form-grid { display: grid; grid-template-columns: 1fr; gap: .75rem; }
@media (min-width: 640px) {
    .form-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .form-grid-4 { grid-template-columns: repeat(4, 1fr); }
}
.form-grid .btn,
.form-grid .full-row { grid-column: 1 / -1; }

.stack > * + * { margin-top: 1.5rem; }
.stack-sm > * + * { margin-top: .75rem; }
.inline-gap > * + * { margin-left: .5rem; }

.max-w-md { max-width: 28rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }

.split { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: .875rem; }
.stat-value { font-size: 1.5rem; font-weight: 600; margin-top: .25rem; }
.stat-label { color: var(--color-text-muted); font-size: .875rem; }
.stat-link { font-size: .875rem; margin-top: .5rem; display: inline-block; }

.chart-card { flex: 1 1 320px; min-width: 0; }
.chart-card canvas { max-width: 100%; }

.sidebar-nav-list { list-style: none; padding: 0; margin: 0; }
.sidebar-nav-list li { margin-bottom: .15rem; }
.sidebar-nav-list a {
    display: block;
    border-radius: 8px;
    padding: .5rem .75rem;
    font-size: .875rem;
    color: var(--color-text-muted);
}
.sidebar-nav-list a:hover { background: #f3f4f6; text-decoration: none; }
.sidebar-nav-list a.is-active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 500; }

.side-nav-layout { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.side-nav-layout > nav { flex: 0 0 12rem; }
.side-nav-layout > .side-nav-content { flex: 1 1 300px; min-width: 0; }
.side-nav-layout > .side-nav-content > * + * { margin-top: 1rem; }

.perm-group { margin-bottom: 1.25rem; }
.perm-group-title { font-size: .875rem; font-weight: 600; margin-bottom: .5rem; }
.perm-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; }
@media (min-width: 640px) { .perm-grid { grid-template-columns: repeat(2, 1fr); } }

/* ===== Modal (used with Alpine's x-show/x-transition — this just supplies the CSS Alpine's classes assumed) ===== */
.modal-wrap { position: fixed; inset: 0; z-index: 50; overflow-y: auto; padding: 1.5rem 1rem; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(107, 114, 128, .75); }
.modal-panel {
    position: relative;
    margin: 0 auto;
    max-width: 32rem;
    width: 100%;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
    padding: 1.5rem;
}
