:root {
    --bg: #f6f8fc;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --text: #101828;
    --muted: #667085;
    --line: #e4e7ec;
    --blue: #2563eb;
    --cyan: #0891b2;
    --violet: #7c3aed;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --shadow-sm: 0 8px 24px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 18px 50px rgba(16, 24, 40, 0.10);
    --radius: 8px;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background:
        linear-gradient(rgba(37, 99, 235, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(124, 58, 237, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, #ffffff 0%, #f7f9fd 42%, #eef4ff 100%);
    background-size: 34px 34px, 34px 34px, 100% 100%;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(110deg, transparent 0%, rgba(37, 99, 235, 0.08) 36%, transparent 58%),
        linear-gradient(250deg, transparent 0%, rgba(8, 145, 178, 0.07) 42%, transparent 68%);
    animation: ambientSweep 16s ease-in-out infinite alternate;
    z-index: -1;
}

a { color: inherit; text-decoration: none; }

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

@keyframes ambientSweep {
    from { opacity: .65; transform: translate3d(-2%, 0, 0); }
    to { opacity: 1; transform: translate3d(2%, 0, 0); }
}

@keyframes riseIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes sheen {
    from { transform: translateX(-120%); }
    to { transform: translateX(120%); }
}

.site-header,
.admin-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    padding: 0 6vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(255, 255, 255, 0.78);
    border-bottom: 1px solid rgba(228, 231, 236, 0.9);
    backdrop-filter: blur(18px);
}

.admin-header {
    background: rgba(16, 24, 40, 0.94);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #0f172a;
    font-size: 22px;
    font-weight: 950;
    letter-spacing: 0;
}

.admin-header .logo {
    color: #fff;
}

.logo::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--blue), var(--cyan) 52%, var(--violet));
    box-shadow: 0 0 22px rgba(37, 99, 235, .38);
}

.top-nav,
.admin-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.top-nav a,
.admin-nav a {
    position: relative;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
    transition: color .18s ease, background .18s ease;
}

.admin-nav a {
    color: #cbd5e1;
}

.top-nav a:hover,
.admin-nav a:hover {
    color: var(--blue);
    background: rgba(37, 99, 235, 0.08);
}

.admin-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.10);
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 58px;
}

.narrow {
    width: min(720px, calc(100% - 32px));
}

.hero {
    position: relative;
    overflow: hidden;
    text-align: center;
    padding: 58px 18px 44px;
}

.hero::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 18px;
    width: min(420px, 72vw);
    height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .42), rgba(124, 58, 237, .42), transparent);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--blue);
    font-size: 14px;
    font-weight: 900;
}

.hero h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 58px);
    line-height: 1.12;
    letter-spacing: 0;
}

.hero p {
    max-width: 720px;
    margin: 16px auto 28px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.7;
}

.btn {
    position: relative;
    overflow: hidden;
    min-height: 40px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1f2937;
    background: #eef4ff;
    font-weight: 900;
    white-space: nowrap;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.38), transparent);
    transform: translateX(-120%);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:hover::before {
    animation: sheen .8s ease;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--cyan) 50%, var(--violet));
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.22);
}

.btn-large {
    min-height: 52px;
    padding: 14px 26px;
    font-size: 16px;
}

.btn-block { width: 100%; }
.btn-small { min-height: 32px; padding: 7px 10px; font-size: 12px; }
.btn-danger { color: #fff; background: var(--red); }
.btn-success { color: #fff; background: var(--green); }

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

.page-head h1,
.page-head .admin-title {
    margin-bottom: 0;
}

.board-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 14px;
}

.section-title h2,
.admin-title {
    margin: 0;
    font-size: 24px;
    letter-spacing: 0;
}

.section-title span {
    color: var(--muted);
    font-size: 14px;
}

.card-list {
    display: grid;
    gap: 14px;
}

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

.carpool-card,
.panel,
.stat-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(228, 231, 236, 0.95);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.carpool-card::before,
.panel::before,
.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--blue), var(--cyan), var(--violet));
    opacity: .8;
}

.carpool-card {
    padding: 18px;
    opacity: 0;
    transform: translateY(14px);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

.carpool-card.is-visible {
    animation: riseIn .42s ease forwards;
}

.carpool-card:hover {
    transform: translateY(-4px);
    border-color: rgba(37, 99, 235, .30);
    box-shadow: var(--shadow-md);
    background: rgba(255,255,255,.96);
}

.carpool-card.completed::before {
    background: linear-gradient(90deg, var(--green), var(--cyan));
}

.card-head,
.metric-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
}

.card-head {
    padding-bottom: 14px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.card-head strong {
    font-size: 18px;
    line-height: 1.35;
}

.badge,
.status-pill {
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 900;
}

.badge-blue,
.status-pending {
    color: #1d4ed8;
    background: #dbeafe;
}

.badge-green,
.status-completed {
    color: #15803d;
    background: #dcfce7;
}

.status-warning {
    color: #b45309;
    background: #fef3c7;
}

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

.metric-row {
    padding: 7px 0;
    color: var(--muted);
    line-height: 1.55;
}

.metric-column {
    display: grid;
    justify-content: stretch;
}

.metric-row b {
    color: var(--text);
}

.time-text,
.muted-line,
.form-tip {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.time-text { margin: 10px 0 14px; }
.muted-line { margin: 14px 0 0; }

.home-tabs,
.admin-tabs {
    display: grid;
    gap: 20px;
}

.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-end;
    border-bottom: 1px solid rgba(228, 231, 236, 0.95);
}

.tab-btn {
    position: relative;
    min-height: 48px;
    padding: 0 0 13px;
    border: 0;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--muted);
    background: transparent;
    font-family: inherit;
    font-weight: 950;
}

.tab-btn::after {
    content: "";
    position: absolute;
    left: 0;
    right: 100%;
    bottom: -1px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--blue), var(--cyan), var(--violet));
    transition: right .26s ease;
}

.tab-btn span {
    min-width: 22px;
    min-height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
    background: #eef4ff;
    font-size: 12px;
}

.tab-btn.active {
    color: var(--text);
}

.tab-btn.active::after {
    right: 0;
}

.tab-btn.active span {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--violet));
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.empty-state,
.empty-cell {
    padding: 42px 20px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius);
    color: var(--muted);
    background: rgba(255,255,255,.65);
    text-align: center;
}

.panel {
    padding: 26px;
}

.panel h1 {
    margin: 0 0 10px;
    font-size: 28px;
}

.help-panel { margin-top: 24px; }

.help-content {
    padding-top: 8px;
    color: #344054;
    font-size: 16px;
    line-height: 1.9;
}

.help-editor {
    min-height: 420px;
    line-height: 1.75;
}

.form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.form label {
    display: grid;
    gap: 8px;
}

.form span {
    color: #344054;
    font-size: 14px;
    font-weight: 900;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: var(--radius);
    outline: none;
    color: var(--text);
    background: rgba(255,255,255,.92);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.alert {
    margin: 14px 0;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 800;
}

.alert-success {
    color: #166534;
    background: #dcfce7;
}

.alert-error {
    color: #991b1b;
    background: #fee2e2;
}

.info-box,
.detail-grid,
.stat-grid {
    display: grid;
    gap: 14px;
}

.info-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 18px 0;
}

.info-box div,
.detail-grid div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 5px;
    background: rgba(248, 250, 252, .86);
}

.info-box span,
.detail-grid span,
.stat-card span {
    color: var(--muted);
    font-size: 13px;
}

.info-box b,
.detail-grid b {
    font-size: 16px;
}

.admin-bg {
    background: linear-gradient(135deg, #eff6ff 0%, #f7f5ff 100%);
}

.login-shell {
    width: min(440px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    place-items: center;
}

.login-panel { width: 100%; }

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

.stat-card {
    padding: 22px;
    display: grid;
    gap: 10px;
    transition: transform .18s ease, box-shadow .18s ease;
}

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

.stat-card b {
    font-size: 34px;
}

.stat-card.urgent {
    border-color: rgba(245, 158, 11, 0.34);
    background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, #fffbeb 100%);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

.data-table th {
    color: #344054;
    background: #f8fafc;
    font-weight: 950;
}

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

.actions form { margin: 0; }

.contact-cell {
    color: #111827;
    font-weight: 900;
}

.inline-form,
.project-add-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) 120px auto;
    gap: 12px;
    align-items: center;
}

.project-add-form {
    grid-template-columns: minmax(180px, 1fr) 140px 110px auto;
}

.table-edit-form,
.project-edit-form,
.option-edit-form {
    display: grid;
    gap: 8px;
    align-items: center;
}

.table-edit-form {
    grid-template-columns: minmax(180px, 1fr) 64px 90px auto;
}

.project-edit-form {
    grid-template-columns: minmax(180px, 1fr) 120px 90px auto;
}

.option-edit-form {
    grid-template-columns: 90px minmax(160px, 1fr) 90px auto;
}

.table-edit-form input,
.project-edit-form input,
.option-edit-form input {
    min-height: 34px;
    padding: 7px 9px;
}

.table-status {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1020px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .board-grid,
    .stat-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .admin-header {
        height: auto;
        min-height: 72px;
        align-items: flex-start;
        flex-direction: column;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .admin-nav {
        justify-content: flex-start;
    }

    .inline-form,
    .project-add-form,
    .table-edit-form,
    .project-edit-form,
    .option-edit-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding: 0 16px;
    }

    .container {
        width: min(100% - 24px, 1180px);
        padding-top: 24px;
    }

    .hero {
        padding-top: 34px;
    }

    .hero p {
        font-size: 16px;
    }

    .card-grid,
    .info-box {
        grid-template-columns: 1fr;
    }

    .tab-nav {
        gap: 22px;
    }

    .panel {
        padding: 20px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .card-head,
    .metric-row {
        align-items: flex-start;
    }
}
