@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&family=Noto+Serif+SC:wght@600;700&display=swap');

:root {
    --bg: #f4f2ed;
    --bg-alt: #ebe8e1;
    --surface: #ffffff;
    --surface-2: #faf9f7;
    --border: #ddd8cf;
    --border-strong: #c9c2b6;
    --text: #1c1b19;
    --text-secondary: #5c5850;
    --text-muted: #8a847a;
    --accent: #c4471c;
    --accent-hover: #a33a15;
    --accent-soft: #fdf0ea;
    --accent-muted: #e8c4b4;
    --dark: #1c1b19;
    --dark-soft: #2e2d2a;
    --success: #2d6a4f;
    --success-soft: #eaf4ee;
    --danger: #b42318;
    --danger-soft: #fdeeed;
    --warning: #b45309;
    --warning-soft: #fef6e8;
    --info: #1d4ed8;
    --info-soft: #eff6ff;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(28, 27, 25, 0.04);
    --shadow: 0 4px 16px rgba(28, 27, 25, 0.06);
    --shadow-lg: 0 12px 40px rgba(28, 27, 25, 0.1);
    --font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Noto Serif SC', Georgia, serif;
    --header-h: 64px;
    --bottom-nav-h: 62px;
    --sidebar-w: 220px;
    --transition: 0.2s ease;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100%;
}

/* ===== APP SHELL ===== */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
}

.sidebar {
    display: none;
    width: var(--sidebar-w);
    background: var(--dark);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
}

@media (min-width: 1024px) {
    .sidebar { display: flex; }
    .app-main { margin-left: var(--sidebar-w); }
    body { padding-bottom: 0; }
}

.sidebar-brand {
    padding: 1.4rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar-brand i {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 0.85rem;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-nav a i { width: 18px; text-align: center; font-size: 0.95rem; }

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

.sidebar-nav a.active {
    color: #fff;
    background: var(--accent);
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-credits {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}

.sidebar-login-btn {
    display: block;
    text-align: center;
    padding: 0.65rem;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    transition: var(--transition);
}

.sidebar-login-btn:hover { background: var(--accent-hover); }

/* ===== MOBILE HEADER ===== */
.mobile-header {
    display: flex;
    flex-shrink: 0;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    height: 52px;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 1024px) {
    .mobile-header { display: none; }
}

.mobile-header .logo {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header .logo i {
    color: var(--accent);
    font-size: 1.1rem;
}

.mobile-header-credits {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.mobile-header-credits strong { color: var(--accent); }

/* ===== MOBILE BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--dark);
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: var(--bottom-nav-h);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

@media (min-width: 1024px) {
    .bottom-nav { display: none; }
}

.bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: rgba(255,255,255,0.45);
    font-size: 0.65rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.bottom-nav .nav-item i { font-size: 1.15rem; }

.bottom-nav .nav-item.active {
    color: #fff;
}

.bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
}

/* Legacy desktop navbar - hidden */
.navbar-desktop { display: none !important; }

/* ===== MAIN CONTENT ===== */
.app-main {
    flex: 1;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-bottom: calc(var(--bottom-nav-h) + 16px);
}

@media (min-width: 1024px) {
    .app-main {
        padding-bottom: 0;
        width: auto;
    }
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .container { padding: 2rem 1.5rem; }
}

.container-narrow { max-width: 720px; }
.container-wide { max-width: 1400px; }

/* ===== TYPOGRAPHY ===== */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.section-title i {
    display: none;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

.page-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: var(--border-strong);
}

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

.card-body { padding: 1.25rem; }

.card-padded { padding: 1.5rem; }

/* ===== BUTTONS ===== */
.btn {
    padding: 0.65rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font);
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.4;
    white-space: nowrap;
}

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

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

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

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--border-strong);
}

.btn-dark {
    background: var(--dark);
    color: #fff;
    border-color: var(--dark);
}

.btn-dark:hover { background: var(--dark-soft); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #f5c4c0;
}

.btn-danger:hover { background: #fad4d1; }

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.82rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 0.95rem; }
.btn-block { width: 100%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.1rem; }

label, .form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
textarea,
select,
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus, .form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

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

/* ===== ALERTS ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.88rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid;
}

.alert-success { background: var(--success-soft); color: var(--success); border-color: #b7dfc8; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c4c0; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #fde0a8; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }

/* ===== GRID ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 768px) {
    .grid, .grid-2, .grid-3 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .grid, .grid-2, .grid-3 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

/* ===== BADGES & TAGS ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
}

.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-muted); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: #b7dfc8; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #f5c4c0; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: #fde0a8; }
.badge-muted { background: var(--bg); color: var(--text-muted); border-color: var(--border); }

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== BACK LINK ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    transition: color var(--transition);
}

.back-link:hover { color: var(--accent); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.35;
}

.empty-state h3 {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 2rem;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.pagination a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pagination a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }

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

.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-2);
}

.table tr:hover td { background: var(--surface-2); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 27, 25, 0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 440px;
    width: 100%;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    margin-bottom: 1rem;
    padding-right: 2rem;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
