@font-face {
    font-family: 'Fira Code';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-code-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Code';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-code-500.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Code';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-code-600.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Code';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-code-700.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-sans-300.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-sans-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-sans-500.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-sans-600.woff2') format('woff2');
}

@font-face {
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/fonts/fira-sans-700.woff2') format('woff2');
}

:root {
    --bg: #F9FAFB;
    --sidebar: #374151;
    --card: #ffffff;
    --text: #111827;
    --text-body: #4B5563;
    --primary: #10B981;
    --primary-hover: #059669;
    --secondary: #6EE7B7;
    --cta: #10B981;
    --cta-hover: #059669;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --success: #10B981;
    --warning: #F59E0B;
    --border: #E5E7EB;
    --muted: #6B7280;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --transition: 200ms ease;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Fira Sans', "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text-body);
    line-height: 1.6;
}

.layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, var(--sidebar) 0%, #1F2937 100%);
    color: #fff;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar h1 {
    margin: 0 0 28px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar nav a {
    color: #CBD5E1;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateX(4px);
}

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

.user-info {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 13px;
    color: #94A3B8;
}

.user-info strong {
    color: #fff;
    font-weight: 500;
}

.content {
    flex: 1;
    padding: 32px;
    max-width: none;
    min-width: 0;
}

.content-auth {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #374151 0%, #1F2937 100%);
    min-height: 100vh;
    width: 100vw;
    max-width: none;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.modal-backdrop.show {
    display: flex;
}

.modal-card {
    width: min(860px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    padding: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.auth-card {
    width: 400px;
    border: none;
    box-shadow: var(--shadow-lg);
}

h2, h3 {
    margin-top: 0;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

h3 {
    font-size: 1.125rem;
    margin-bottom: 16px;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.multi-col {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}

input, select, button {
    font: inherit;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

button, .btn {
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

button:hover, .btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

button:active, .btn:active {
    transform: translateY(0);
}

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

button.danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-cta {
    background: var(--cta);
}

.btn-cta:hover {
    background: var(--cta-hover);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

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

.btn-outline:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: none;
    transform: none;
}

.btn-pill {
    border-radius: 999px !important;
    height: 32px;
    padding: 0 12px !important;
    font-size: 13px !important;
    line-height: 1;
    box-sizing: border-box;
}

summary.summary-pill {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #BAE6FD;
    background: #E0F2FE;
    color: #0369A1;
    font-size: 13px;
    line-height: 1;
    font-weight: 600;
    box-sizing: border-box;
}

summary.summary-pill::marker,
summary.summary-pill::-webkit-details-marker {
    display: none;
    content: "";
}

summary.summary-pill:hover {
    background: #BAE6FD;
    border-color: #7DD3FC;
    color: #075985;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
}

th {
    background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: #F8FAFC;
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 14px;
}

.flash-list {
    margin-bottom: 16px;
}

.content-auth .flash-list {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    z-index: 10;
}

.flash {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.flash-success {
    background: #DCFCE7;
    color: #166534;
    border-left: 4px solid var(--success);
}

.flash-danger {
    background: #FEE2E2;
    color: #991B1B;
    border-left: 4px solid var(--danger);
}

.flash-warning {
    background: #FEF3C7;
    color: #92400E;
    border-left: 4px solid var(--warning);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.stat-card.stat-cta::before {
    background: var(--cta);
}

.stat-card.stat-success::before {
    background: var(--success);
}

.stat-card.stat-warning::before {
    background: var(--warning);
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    margin-top: 8px;
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    font-family: 'Fira Code', monospace;
}

.stat-trend {
    margin-top: 8px;
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    margin-bottom: 0;
}

.hint {
    color: var(--muted);
    font-size: 13px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 16px;
    }

    .sidebar h1 {
        margin-bottom: 16px;
    }

    .sidebar nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar nav a {
        padding: 8px 12px;
    }

    .sidebar nav a:hover {
        transform: none;
    }

    .user-info {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .auth-card {
        width: 100%;
        max-width: 420px;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .multi-col {
        grid-template-columns: 1fr;
    }
}

textarea {
    font: inherit;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    resize: vertical;
    min-height: 96px;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

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

.two-col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.soft-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.soft-card-danger {
    border-color: #fecaca;
    background: linear-gradient(180deg, #fff7f7 0%, #fff1f2 100%);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e8f8f1;
    color: #129a67;
    font-size: 12px;
    font-weight: 600;
}

.status-chip-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.mini-stat-label {
    font-size: 12px;
    color: var(--muted);
}

.mini-stat-value {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.inline-edit {
    position: relative;
}

.inline-edit[open] {
    min-width: 360px;
}

@media (max-width: 720px) {
    .mini-stats {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
}
