/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #f5f5f7;
    --surface:     #ffffff;
    --surface-2:   #f5f5f7;
    --border:      rgba(0,0,0,0.08);
    --border-focus: #0071e3;
    --text:        #1d1d1f;
    --text-2:      #6e6e73;
    --text-3:      #aeaeb2;
    --accent:      #7c3aed;
    --accent-hover:#6d28d9;
    --danger:      #ff3b30;
    --success:     #34c759;
    --warning:     #ff9f0a;
    --radius:      14px;
    --radius-sm:   10px;
    --radius-xs:   7px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:        0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
    --shadow-lg:     0 8px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    --shadow-accent: 0 4px 16px rgba(0,113,227,0.18);
    --card:          #ffffff;
    --muted:         #6e6e73;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-2); line-height: 1.6; }

/* ── Layout helpers ───────────────────────────────────────────── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1.25rem;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.card-sm {
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

/* ── Form elements ────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
}

input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
    background: var(--surface);
}

input::placeholder { color: var(--text-3); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--text-3); cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover { background: #ebebed; }

.btn-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    border: 1.5px solid rgba(255, 59, 48, 0.2);
}

.btn-danger:hover { background: rgba(255, 59, 48, 0.18); }

.btn-success {
    background: rgba(52, 199, 89, 0.12);
    color: #248a3d;
    border: 1.5px solid rgba(52, 199, 89, 0.25);
}

.btn-success:hover { background: rgba(52, 199, 89, 0.2); }

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    border-radius: var(--radius-xs);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-xs);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    transition: background 0.12s, color 0.12s;
}

.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* ── Nav bar ──────────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.navbar-brand svg { color: var(--accent); }

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-username {
    font-size: 0.85rem;
    color: var(--text-2);
    font-weight: 500;
}

/* ── Badge ────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 99px;
    letter-spacing: 0.02em;
}

.badge-blue    { background: rgba(0,113,227,0.1);   color: var(--accent); }
.badge-green   { background: rgba(52,199,89,0.12);  color: #248a3d; }
.badge-orange  { background: rgba(255,159,10,0.12); color: #b25000; }
.badge-red     { background: rgba(255,59,48,0.1);   color: var(--danger); }
.badge-gray    { background: var(--surface-2);      color: var(--text-2); border: 1px solid var(--border); }

/* ── Alert ────────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: none;
}

.alert.show { display: block; }
.alert-error   { background: rgba(255,59,48,0.08);  color: #c0392b; border: 1px solid rgba(255,59,48,0.15); }
.alert-success { background: rgba(52,199,89,0.08);  color: #248a3d; border: 1px solid rgba(52,199,89,0.2); }
.alert-info    { background: rgba(0,113,227,0.07);  color: #0058b0; border: 1px solid rgba(0,113,227,0.15); }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(0,113,227,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Divider ──────────────────────────────────────────────────── */
.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--text-3);
    font-size: 0.8rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Progress bar ─────────────────────────────────────────────── */
.progress {
    width: 100%;
    height: 6px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

.progress-blue   { background: var(--accent); }
.progress-green  { background: var(--success); }
.progress-orange { background: var(--warning); }
.progress-red    { background: var(--danger); }

/* ── Stat card ────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
}

@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 1.125rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-3);
}

/* ── App tile grid ────────────────────────────────────────────── */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 480px) {
    .tile-grid { grid-template-columns: repeat(3, 1fr); }
}

.app-tile {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border: 1.5px solid transparent;
}

.app-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(0,113,227,0.15);
}

.app-tile:active { transform: scale(0.97); }

.tile-icon-wrap {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.tile-name {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

.tile-desc {
    font-size: 0.75rem;
    color: var(--text-2);
    text-align: center;
    line-height: 1.4;
}

/* ── Table ────────────────────────────────────────────────────── */
.table-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

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

thead {
    background: var(--surface-2);
}

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

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0,0,0,0.018); }

/* ── Utility ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-2); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
