:root {
    --bg: #f3f5fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-700: #1d4ed8;
    --danger: #dc2626;
    --danger-700: #b91c1c;
    --border: #e2e8f0;
    --shadow-sm: 0 8px 18px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.12);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 40%, #f1f5f9 100%);
    margin: 0;
    color: var(--text);
    line-height: 1.6;
}

a {
    color: inherit;
}

.app-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
}

.container {
    width: min(1200px, 92%);
    margin: 28px auto;
    padding-bottom: 32px;
}

.site-header {
    background: #0f172a;
    color: #e2e8f0;
    padding: 4px 0;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.site-header .brand {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.2px;
}

.site-header nav a {
    color: #e2e8f0;
    margin-left: 0;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.site-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.site-header nav a:hover {
    background: rgba(148, 163, 184, 0.15);
    border-color: rgba(148, 163, 184, 0.25);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
}

.card {
    background: var(--surface);
    padding: 24px 26px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
    border: 1px solid var(--border);
}

.auth-shell {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 180px);
}

.auth-card {
    width: min(440px, 100%);
}

.grid .card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card h2,
.card h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

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

.grid.single {
    grid-template-columns: minmax(260px, 520px);
    justify-content: flex-start;
}

.meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
}

.meta div {
    margin: 0;
}

.meta .badge {
    align-self: flex-start;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.btn:hover {
    border-color: #c7d2fe;
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.12);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: #fff;
    border-color: transparent;
}

.btn.primary:hover {
    background: linear-gradient(135deg, var(--primary-700), #4338ca);
    border-color: transparent;
}

.btn.danger {
    background: var(--danger);
    color: #fff;
    border-color: transparent;
}

.btn.danger:hover {
    background: var(--danger-700);
    border-color: transparent;
}

.btn.ghost {
    background: var(--surface-muted);
    color: #334155;
    border-color: #e2e8f0;
}

.btn.ghost:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.btn.disabled {
    background: #e5e7eb;
    color: #6b7280;
    border-color: #e5e7eb;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

form {
    margin: 0;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-stack .btn {
    align-self: flex-start;
}

input, textarea, select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    width: 100%;
    font-size: 14px;
    color: var(--text);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

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

table thead th {
    color: #475569;
    font-weight: 600;
    background: #f8fafc;
    font-size: 13px;
}

table tbody tr:nth-child(even) {
    background: #f9fafb;
}

table tbody tr:hover {
    background: #eef2ff;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.actions form {
    margin: 0;
}

.actions-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
    gap: 8px;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #fecaca;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #bbf7d0;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    width: min(420px, 90%);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
    text-align: center;
    border: 1px solid var(--border);
    animation: modal-pop 0.2s ease;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-title.success {
    color: #166534;
}

.modal-title.error {
    color: #991b1b;
}

.modal-message {
    color: #475569;
    margin-bottom: 16px;
}

.notice {
    background: #e0f2fe;
    color: #075985;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid #bae6fd;
}

.empty {
    color: #6b7280;
    background: #f8fafc;
    border: 1px dashed var(--border);
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.proof li {
    margin: 6px 0;
}

.desc {
    color: #374151;
    line-height: 1.7;
}

label {
    font-weight: 600;
    color: #334155;
    font-size: 14px;
}

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

.page-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.page-header .actions {
    margin-left: auto;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.detail-header h2 {
    margin-bottom: 6px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 14px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: #e5e7eb;
    color: #374151;
    font-weight: 600;
    border: 1px solid transparent;
}

.badge.active {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.badge.locked {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde68a;
}

.badge.drawn {
    background: #e0f2fe;
    color: #075985;
    border-color: #bae6fd;
}

.badge.cancelled {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.section-title {
    font-weight: 600;
    margin-top: 12px;
}

.subtle {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

@media (max-width: 720px) {
    .site-header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .site-header nav a {
        margin-left: 0;
    }

    .page-header {
        align-items: flex-start;
    }

    .actions {
        width: 100%;
    }
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}
