/* ===== CSS Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:      #2563eb;
    --primary-dark: #1d4ed8;
    --accent:       #0f766e;
    --bg:           #f4f6f8;
    --surface:      #ffffff;
    --surface-soft: #f8fafc;
    --border:       #dfe5ee;
    --text:         #111827;
    --text-muted:   #64748b;
    --danger:       #dc2626;
    --success:      #16a34a;
    --warning:      #b45309;
    --radius:       8px;
    --radius-sm:    6px;
    --shadow:       0 8px 24px rgba(15, 23, 42, .08);
    --shadow-lg:    0 16px 40px rgba(15, 23, 42, .12);
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s, transform .1s;
    white-space: nowrap;
    color: inherit;
    background: transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost    { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-block    { width: 100%; }
.btn-sm       { padding: 6px 10px; font-size: 13px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select,
.link-display input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.link-display input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* ===== Alerts ===== */
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ===== Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 18px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .52);
}
.modal-box {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    width: min(520px, 100%);
    box-shadow: var(--shadow-lg);
}
.modal-box h2 { font-size: 18px; margin-bottom: 8px; }
.modal-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.modal-box-sm { max-width: 400px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.link-display { display: flex; gap: 8px; }
.link-display input { flex: 1; font-size: 13px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

@media (max-width: 640px) {
    .btn { padding: 8px 12px; }
    .modal { align-items: flex-end; padding: 10px; }
    .modal-box { padding: 20px; }
    .modal-actions { justify-content: stretch; }
    .modal-actions .btn { flex: 1; }
    .link-display { flex-direction: column; }
}