:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f4f5f9;
    --card-bg: #ffffff;
    --text: #1f2432;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.topbar-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
}

.brand-logo,
.preview-logo,
.login-logo {
    display: block;
    max-height: 38px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
}

.brand-text {
    line-height: 1.2;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    margin-left: 16px;
}

.nav-link:hover { color: var(--primary); }

h1 { font-size: 1.6rem; margin-bottom: 4px; }
h2 { font-size: 1.2rem; margin-top: 32px; }
p.subtitle { color: var(--muted); margin-top: 0; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.dashboard-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 20px;
    padding: 6px;
    background: #eef2ff;
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 14px;
    width: fit-content;
    max-width: 100%;
}

.dashboard-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.81rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.2;
}

.dashboard-menu:hover,
.dashboard-menu.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
}

.file-list { list-style: none; padding: 0; margin: 0; }

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.file-item:last-child { border-bottom: none; }

.public-layout {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.sidebar-panel {
    width: 260px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    position: sticky;
    top: 20px;
}

.sidebar-panel h3 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.sidebar-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
}

.content-panel {
    flex: 1;
}

.file-name { font-weight: 600; }
.file-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.file-desc { color: var(--text); font-size: 0.9rem; margin-top: 4px; }
.file-status {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
}
.status-visible { background: #dcfce7; color: #166534; }
.status-hidden { background: #f3f4f6; color: #4b5563; }

button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.btn {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    display: inline-block;
    padding: 9px 18px;
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.3;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(79, 70, 229, 0.24);
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.18);
}
.btn-danger:hover { background: #b91c1c; }

.btn-secondary {
    background: #6b7280;
    box-shadow: 0 8px 20px rgba(107, 114, 128, 0.18);
}
.btn-secondary:hover { background: #4b5563; }

.btn-toggle {
    background: #0f766e;
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.18);
}
.btn-toggle:hover { background: #115e59; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.35);
    box-shadow: none;
}

.btn-outline:hover {
    background: rgba(79, 70, 229, 0.05);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 14px;
}

form input[type="text"],
form input[type="password"],
form input[type="file"],
form select,
form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

form textarea { resize: vertical; min-height: 70px; }

.file-subject,
.file-category {
    display: inline-block;
    margin-top: 6px;
    margin-right: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.file-subject {
    background: #ecfeff;
    color: #0f766e;
}

.file-category {
    background: #eef2ff;
    color: var(--primary);
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 0;
}

.center-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-page .card { width: 100%; max-width: 380px; }

.login-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.login-logo {
    max-height: 64px;
    max-width: 180px;
}

.badge {
    display: inline-block;
    background: #eef2ff;
    color: var(--primary);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 8px;
}

.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.subject-form {
    margin-bottom: 16px;
}

.subject-manager-grid {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 12px;
    align-items: end;
}

.subject-list-box {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.subject-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fafc;
}

.subject-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.file-editor {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.inline-edit-form {
    display: block;
}

.inline-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 12px;
}

.inline-edit-form label {
    margin-top: 0;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: min(480px, calc(100% - 32px));
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}

.modal-form label {
    margin-top: 0;
}
