/* ── SJTU Court · Warm Minimalism ───────────────────── */

:root {
    --bg:          #F8F5F0;
    --surface:     #FFFFFF;
    --text:        #3D3329;
    --text-2:      #9B8E7E;
    --text-3:      #C4BAB0;
    --accent:      #C67B4B;
    --accent-soft: #F0E1D4;
    --border:      #E8E1D8;
    --hover:       #F2EDE6;
    --ok:          #7B9E6B;
    --ok-bg:       #F0F5ED;
    --err:         #C4685A;
    --err-bg:      #FDF0ED;
    --warn:        #D4A563;
    --warn-bg:     #FDF6ED;

    --font-display: 'Cormorant Garamond', 'Noto Serif SC', serif;
    --font-body:    'Outfit', 'PingFang SC', 'Microsoft YaHei', sans-serif;

    --radius:    6px;
    --shadow-sm: 0 1px 2px rgba(61,51,41,.04);
    --ease:      cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────────── */

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* ── Typography ────────────────────────────────────── */

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--text);
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.6rem; margin-bottom: 0.2rem; }
h3 { font-size: 1.15rem; }

.page-sub {
    color: var(--text-2);
    font-weight: 300;
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity .2s var(--ease);
}
a:hover { opacity: .7; }

/* ── Navigation ────────────────────────────────────── */

nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.04em;
}
.nav-brand:hover { opacity: 1; color: var(--accent); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}
.nav-links a {
    color: var(--text-2);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.03em;
    padding: 0.3rem 0;
    border-bottom: 1.5px solid transparent;
    transition: color .2s var(--ease), border-color .2s var(--ease);
}
.nav-links a:hover {
    color: var(--text);
    opacity: 1;
}
.nav-links a.active {
    color: var(--text);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

.nav-lock-form {
    margin: 0;
}

.nav-lock {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.38rem 0.8rem;
    cursor: pointer;
    transition: all .2s var(--ease);
}
.nav-lock:hover {
    color: var(--text);
    background: var(--hover);
    border-color: #d5cdc3;
}

/* ── Main ──────────────────────────────────────────── */

main {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
    flex: 1;
}

.auth-main {
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* ── Cards ─────────────────────────────────────────── */

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

.card-header {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-2);
    margin-bottom: 1.2rem;
}

/* ── Venue Tabs ────────────────────────────────────── */

.venue-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.venue-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--text-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: all .2s var(--ease);
}
.venue-tab:hover {
    color: var(--text);
    border-color: #d5cdc3;
    background: var(--hover);
}
.venue-tab.active {
    color: #8B5A30;
    background: var(--accent-soft);
    border-color: var(--accent);
    font-weight: 500;
}

.sport-tag {
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
    background: var(--hover);
    color: var(--text-2);
    font-weight: 400;
}
.venue-tab.active .sport-tag {
    background: rgba(139,90,48,.12);
    color: #8B5A30;
}

/* ── Forms ─────────────────────────────────────────── */

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.02em;
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .2s var(--ease);
}
input:focus {
    border-color: var(--accent);
}
input::placeholder {
    color: var(--text-3);
    font-weight: 300;
}

/* ── Buttons ───────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s var(--ease);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: #b56d3f;
    border-color: #b56d3f;
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--hover);
    color: var(--text);
}

.btn-danger {
    background: transparent;
    color: var(--err);
    border-color: transparent;
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
}
.btn-danger:hover {
    background: var(--err-bg);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Loading spinner ───────────────────────────────── */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}

.loading-text {
    color: var(--text-3);
    font-size: 0.88rem;
    font-weight: 300;
}

/* ── Badges ────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-err  { background: var(--err-bg);  color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-mute { background: var(--hover);   color: var(--text-2); }

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.dot-ok   { background: var(--ok); }
.dot-err  { background: var(--err); }
.dot-warn { background: var(--warn); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .3; }
}

/* ── Tables ────────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-2);
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #f0ebe4;
    vertical-align: middle;
}

tbody tr {
    transition: background .15s var(--ease);
}
tbody tr:hover {
    background: var(--hover);
}
tbody tr:last-child td {
    border-bottom: none;
}

tr.row-ok  td { background: var(--ok-bg); }
tr.row-err td { background: var(--err-bg); }
tr.row-skip td { background: var(--hover); }
tr.row-ok:hover td  { background: #e6efe3; }
tr.row-err:hover td { background: #f8e5e1; }

/* ── Schedule grid ─────────────────────────────────── */

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

.schedule-table {
    font-size: 0.82rem;
    min-width: 700px;
}

.schedule-table thead th {
    text-align: center;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 1;
}
.schedule-table thead th:first-child {
    text-align: right;
    padding-right: 1rem;
}

.schedule-table tbody td {
    text-align: center;
    padding: 0.3rem 0.25rem;
}
.schedule-table tbody td:first-child {
    text-align: right;
    padding-right: 1rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    font-size: 0.78rem;
    font-weight: 400;
    white-space: nowrap;
    background: var(--bg);
    border-right: 1px solid var(--border);
}

.schedule-table select {
    width: 100%;
    padding: 0.25rem 0.2rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: all .15s var(--ease);
    text-align: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.schedule-table select:hover {
    background: var(--hover);
    border-color: var(--border);
}
.schedule-table select:focus {
    border-color: var(--accent);
    background: var(--surface);
}
/* Highlight cells that have an account selected */
.schedule-table select.has-value {
    background: var(--accent-soft);
    font-weight: 500;
    color: #8B5A30;
    border-color: transparent;
}
.schedule-table select.has-value:hover {
    border-color: var(--accent);
}

/* ── Actions bar ───────────────────────────────────── */

.actions-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.msg-ok  { color: var(--ok);  font-size: 0.82rem; font-weight: 500; }
.msg-err { color: var(--err); font-size: 0.82rem; font-weight: 500; }

/* ── Account cards ─────────────────────────────────── */

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

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color .2s var(--ease);
    box-shadow: var(--shadow-sm);
}
.account-card:hover {
    border-color: #d5cdc3;
}

.account-card .ac-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.account-card .ac-name {
    font-weight: 500;
    font-size: 0.95rem;
}
.account-card .ac-user {
    font-size: 0.78rem;
    color: var(--text-2);
    font-weight: 300;
}
.account-card .ac-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

/* ── Password gate ─────────────────────────────────── */

.unlock-form {
    width: min(100%, 360px);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.unlock-form input[type="password"] {
    text-align: center;
    padding: 0.85rem 1rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.unlock-form.is-error input[type="password"] {
    border-color: var(--err);
    color: var(--err);
}

.unlock-form button {
    width: 100%;
    padding: 0.8rem 1rem;
}

/* ── Empty state ───────────────────────────────────── */

.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-3);
    font-weight: 300;
}
.empty a {
    font-weight: 500;
}

/* ── Footer ────────────────────────────────────────── */

footer {
    text-align: center;
    padding: 2rem;
    font-size: 0.72rem;
    color: var(--text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 400;
}

/* ── Animations ────────────────────────────────────── */

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

main > * {
    animation: fadeUp .35s var(--ease) both;
}
main > *:nth-child(2) { animation-delay: .05s; }
main > *:nth-child(3) { animation-delay: .1s; }
main > *:nth-child(4) { animation-delay: .15s; }

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 640px) {
    main { padding: 1.5rem 1rem 3rem; }
    .nav-inner { padding: 0 1rem; }
    .nav-links { gap: 0.75rem; }
    .form-row { grid-template-columns: 1fr; }
    h2 { font-size: 1.35rem; }
    .account-grid { grid-template-columns: 1fr; }
    .auth-main { padding: 1rem; }
}
