:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.04);
    --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text);
    line-height: 1.6;
    background: var(--bg);
}

/* ========== Auth ========== */
.auth-body { min-height: 100vh; }

.auth-wrap {
    display: flex;
    min-height: 100vh;
}

.auth-left {
    flex: 1;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-brand h1 { font-size: 28px; margin: 16px 0 8px; font-weight: 700; }
.auth-brand p { opacity: .85; font-size: 16px; }

.brand-icon-lg {
    width: 56px; height: 56px;
    background: rgba(255,255,255,.2);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700;
}

.auth-features { list-style: none; margin: 40px 0; }
.auth-features li {
    padding: 10px 0 10px 28px;
    position: relative;
    opacity: .9;
}
.auth-features li::before {
    content: '';
    position: absolute; left: 0; top: 16px;
    width: 8px; height: 8px;
    background: #60a5fa;
    border-radius: 50%;
}

.auth-copy { margin-top: auto; opacity: .5; font-size: 13px; }

.auth-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.auth-card h2 { font-size: 24px; margin-bottom: 8px; }
.auth-sub { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.auth-hint { margin-top: 20px; font-size: 12px; color: var(--text-muted); line-height: 1.8; text-align: center; }

/* ========== App Shell ========== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; flex-shrink: 0;
}

.sidebar-brand strong { display: block; color: #fff; font-size: 14px; line-height: 1.3; }
.sidebar-brand small { font-size: 11px; opacity: .6; }

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 14px;
    transition: all .15s;
}

.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }

.nav-divider {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 16px 14px 8px;
    color: #475569;
}

.sidebar-footer {
    padding: 16px 20px;
    font-size: 11px;
    color: #475569;
    border-top: 1px solid rgba(255,255,255,.06);
}

.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.breadcrumb { font-size: 16px; font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 16px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
.user-chip small { color: var(--text-muted); display: block; font-size: 12px; }

.avatar {
    width: 36px; height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
}
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }

.page-content { flex: 1; padding: 28px; }

.site-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--card);
}

/* ========== Components ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); text-decoration: none; font-size: 14px; padding: 8px 12px; border-radius: 6px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-link {
    background: none; border: none; color: var(--primary);
    cursor: pointer; font-size: 13px; padding: 0 4px;
}
.btn-link.danger { color: var(--danger); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input:disabled { background: var(--bg); color: var(--text-muted); }

.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row .btn { margin-top: 0; white-space: nowrap; flex-shrink: 0; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .form-actions { margin-top: 8px; }
.form-grid .full { grid-column: 1 / -1; }

.form-msg { margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.form-msg.error, .alert-error { background: #fef2f2; color: var(--danger); }
.form-msg.success, .alert-success { background: #f0fdf4; color: var(--success); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }

.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.panel-head h2 { font-size: 17px; font-weight: 600; }

.link-more { font-size: 13px; color: var(--primary); text-decoration: none; }
.link-more:hover { text-decoration: underline; }

/* Dashboard */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 28px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.welcome-banner h1 { font-size: 22px; margin-bottom: 4px; }
.welcome-banner p { opacity: .9; font-size: 14px; }
.welcome-banner .btn-primary { background: #fff; color: var(--primary); }
.welcome-banner .btn-primary:hover { background: #f8fafc; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.stat-card.highlight { border: 1px solid var(--primary-light); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
}
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }

.stat-num { display: block; font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-link { position: absolute; right: 16px; bottom: 16px; font-size: 12px; color: var(--primary); text-decoration: none; }

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.notice-feed { list-style: none; }
.notice-feed li { padding: 14px 0; border-bottom: 1px solid var(--border); }
.notice-feed li:last-child { border-bottom: none; }
.feed-title { display: block; font-weight: 500; color: var(--text); text-decoration: none; margin: 6px 0 4px; }
.feed-title:hover { color: var(--primary); }
.feed-meta { font-size: 12px; color: var(--text-muted); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 6px;
}
.badge-pin { background: #fef3c7; color: #b45309; }
.badge-cat { background: var(--primary-light); color: var(--primary); }

.attendance-widget { text-align: center; padding: 12px 0; }
.att-time { font-size: 18px; font-weight: 600; margin: 8px 0; }
.att-time.in { color: var(--success); }
.att-time.out { color: var(--primary); }
.att-time.muted { color: var(--text-muted); font-weight: 400; font-size: 14px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.data-table.compact td, .data-table.compact th { padding: 8px 10px; }
.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.empty-cell, .empty-item { color: var(--text-muted); text-align: center; padding: 24px; }

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.status-pending { background: #fef3c7; color: #b45309; }
.status-approved { background: #dcfce7; color: #15803d; }
.status-rejected { background: #fee2e2; color: #b91c1c; }

.text-muted { color: var(--text-muted); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.page-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-info { font-size: 13px; color: var(--text-muted); }

.page-toolbar { margin-bottom: 16px; }
.filter-form select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card);
}

/* Article */
.article-detail { background: var(--card); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.article-detail h1 { font-size: 24px; margin: 12px 0; }
.article-meta { color: var(--text-muted); font-size: 14px; }
.article-body { margin: 28px 0; line-height: 1.8; font-size: 15px; }
.article-footer { border-top: 1px solid var(--border); padding-top: 20px; }

/* Attendance */
.attendance-page { display: grid; grid-template-columns: 360px 1fr; gap: 24px; }
.clock-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow);
}
.clock-date { color: var(--text-muted); margin-bottom: 8px; }
.clock-time { font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); margin-bottom: 20px; }
.clock-status { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 28px; }
.clock-actions { display: flex; flex-direction: column; gap: 12px; }

.tag { padding: 4px 12px; border-radius: 20px; font-size: 12px; }
.tag-success { background: #dcfce7; color: var(--success); }
.tag-muted { background: var(--bg); color: var(--text-muted); }

/* Profile */
.profile-panel { max-width: 560px; }
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.profile-header h2 { font-size: 20px; }

/* Admin */
.admin-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.admin-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s;
    border: 1px solid transparent;
}
.admin-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.1); border-color: var(--primary-light); }
.admin-card.highlight { border-color: var(--primary); background: linear-gradient(135deg, #eff6ff, #fff); }
.admin-card h3 { font-size: 17px; margin-bottom: 8px; }
.admin-card p { color: var(--text-muted); font-size: 14px; }

.inline-actions { display: inline-flex; gap: 8px; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-box {
    background: var(--card);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box.modal-lg { max-width: 560px; }
.modal-box h3 { margin-bottom: 20px; font-size: 18px; }

/* Responsive */
@media (max-width: 1024px) {
    .panel-grid { grid-template-columns: 1fr; }
    .attendance-page { grid-template-columns: 1fr; }
    .admin-cards { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-wrap { margin-left: 0; }
    .auth-wrap { flex-direction: column; }
    .auth-left { padding: 32px 24px; min-height: auto; }
    .auth-right { width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .welcome-banner { flex-direction: column; align-items: flex-start; gap: 16px; }
    .form-row { grid-template-columns: 1fr; }
}
