:root {
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-soft: #eff6ff;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #dbe3ef;
    --text: #172033;
    --text-muted: #64748b;
    --danger: #dc2626;
    --success: #15803d;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
.site-footer {
    padding: 18px 22px 24px;
    color: var(--text-muted);
    text-align: center;
    font-size: 12px;
}
.login-wrap .site-footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    color: rgba(255, 255, 255, .8);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: none; }

.topbar {
    min-height: 76px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--border);
    padding: 10px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 12px rgba(15, 23, 42, .04);
}

.topbar .brand {
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #172554;
    letter-spacing: -.2px;
    flex: 0 0 auto;
}
.topbar .brand img {
    display: block;
    width: 52px !important;
    height: 52px !important;
    max-width: 52px;
    max-height: 52px;
    flex: 0 0 52px;
    object-fit: contain;
    border-radius: 6px;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    margin-left: auto;
    white-space: nowrap;
}

.topbar > .search-bar {
    width: 410px;
    margin: 0 0 0 18px;
    padding: 9px 10px;
    flex: 0 0 410px;
}
.topbar > .search-bar input[type=search] {
    min-width: 0;
}
.topbar > .search-bar select {
    min-width: 0;
}

.badge {
    background: var(--primary);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.badge.admin { background: #6d28d9; }

.container {
    max-width: 1180px;
    margin: 30px auto;
    padding: 0 22px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

h1, h2, h3 { color: #172033; letter-spacing: -.3px; }
h2 { font-size: 22px; margin: 0 0 20px; }
h3 { font-size: 16px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: #334155;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.btn:hover { background: #f8fafc; border-color: #b8c6d9; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.btn-sm { min-height: 31px; padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

input[type=text], input[type=password], input[type=file], input[type=search], select {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    margin-top: 4px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: 7px 10px; }
input:focus, select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
label { font-size: 12px; font-weight: 700; color: #475569; }
.form-group { margin-bottom: 16px; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top right, #3b82f6 0, transparent 38%),
                linear-gradient(135deg, #172554, #1d4ed8);
}
.login-box {
    background: rgba(255, 255, 255, .98);
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
}
.login-box h1 { font-size: 22px; margin: 0 0 4px; }
.login-box p.sub { color: var(--text-muted); margin: 0 0 24px; font-size: 13px; }
.login-box h1 { text-align: center; }
.login-logo {
    display: block;
    width: 150px;
    height: auto;
    margin: 0 auto 18px;
    object-fit: contain;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    color: var(--text-muted);
}
.breadcrumb .sep { color: #94a3b8; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}
.toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
}
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 92px;
    margin: 0 0 20px;
    padding: 18px;
    border: 2px dashed #93c5fd;
    border-radius: 12px;
    background: #eff6ff;
    color: #1e3a8a;
    text-align: center;
    cursor: pointer;
}
.dropzone span { color: var(--text-muted); font-size: 12px; }
.dropzone.is-dragover { background: #dbeafe; border-color: var(--primary); }
.dropzone-input { display: none; }
.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 12px 0 20px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e5eaf1;
    border-radius: 10px;
}
.search-bar input[type=search], .search-bar select { flex: 1; margin-top: 0; }

table.filelist {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
}
table.filelist th {
    text-align: left;
    color: #475569;
    background: #f8fafc;
    font-weight: 700;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .45px;
}
table.filelist td { padding: 12px; border-bottom: 1px solid #edf1f6; vertical-align: middle; }
table.filelist tr:last-child td { border-bottom: 0; }
table.filelist tr:hover { background: #f8fbff; }
.item-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.item-name .icon { font-size: 19px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 58px 20px; color: var(--text-muted); }

.profession-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 20px; }
.profession-summary div { padding: 15px 18px; border: 1px solid #dbeafe; border-radius: 12px; background: linear-gradient(135deg, #eff6ff, #fff); }
.profession-summary strong { display: block; color: var(--primary-dark); font-size: 24px; line-height: 1.1; }
.profession-summary span { color: var(--text-muted); font-size: 12px; }
.profession-section { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 16px; background: #fff; box-shadow: 0 5px 16px rgba(30, 64, 175, .04); transition: border-color .15s, box-shadow .15s, transform .15s; overflow: hidden; }
.profession-section:hover, .profession-section[open] { border-color: #93c5fd; box-shadow: 0 8px 22px rgba(30, 64, 175, .09); }
.profession-card-header { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 16px 18px; cursor: pointer; list-style: none; user-select: none; }
.profession-card-header::-webkit-details-marker { display: none; }
.profession-card-header::before { content: '›'; grid-column: 1; width: 20px; color: var(--primary); font-size: 24px; line-height: 1; transition: transform .15s; }
.profession-section[open] .profession-card-header::before { transform: rotate(90deg); }
.profession-section[open] .profession-card-header { border-bottom: 1px solid #edf2f7; }
.profession-header-meta { grid-column: 3; display: flex; align-items: center; gap: 10px; }
.profession-chevron { color: var(--text-muted); font-size: 20px; line-height: 1; transition: transform .15s; }
.profession-section[open] .profession-chevron { transform: rotate(180deg); }
.profession-content { padding: 0 18px 6px; }
.profession-title { grid-column: 2; display: flex; align-items: center; gap: 12px; min-width: 0; }
.profession-icon { display: flex; flex: 0 0 42px; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid #dbeafe; border-radius: 12px; background: linear-gradient(135deg, #eff6ff, #f8fbff); font-size: 22px; }
.profession-section h3 { margin: 0 0 3px; color: var(--primary-dark); font-size: 15px; line-height: 1.3; }
.profession-count { display: flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px; background: #dbeafe; color: var(--primary-dark); font-size: 12px; font-weight: 700; }
.profession-user { border-top: 1px solid #e8edf4; padding: 16px 0; }
.profession-user:first-of-type { border-top: 0; }
.profession-user-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.profession-user-heading > div { min-width: 0; }
.profession-user-heading strong { display: inline-block; line-height: 1.4; }
.profession-user-heading .text-muted { margin-left: 8px; font-size: 12px; }
.profession-empty { padding: 8px 0 0; font-size: 13px; }
.profession-files { list-style: none; padding: 8px 0 0 18px; margin: 0; }
.profession-files li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid #f1f5f9; }
.profession-files li > span:first-child { flex: 1; font-weight: 500; }
.profession-files .actions { margin-left: auto; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.pagination-link { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; background: #fff; }
.pagination-link:hover, .pagination-link.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.alert { padding: 12px 15px; border-radius: 9px; margin-bottom: 18px; font-size: 13px; border: 1px solid; }
.alert-error { background: #fff7f7; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }

.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    padding: 20px;
    background: rgba(15, 23, 42, .58);
    align-items: center; justify-content: center;
    z-index: 100;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 14px;
    padding: 26px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
}
.modal h3 { margin: 0 0 22px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.upload-preview { max-width: 650px; }
.upload-preview-summary {
    margin: 14px 0 8px;
    font-weight: 700;
    color: var(--primary-dark);
}
.upload-preview-list {
    max-height: 280px;
    overflow-y: auto;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    list-style: none;
}
.upload-preview-list li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    border-bottom: 1px solid #e5eaf1;
    font-size: 13px;
}
.upload-preview-list li:last-child { border-bottom: 0; }
.upload-preview-list small {
    flex: 0 0 auto;
    color: var(--text-muted);
}
.upload-preview-folders {
    max-height: 140px;
    margin-bottom: 14px;
}

@media (max-width: 720px) {
    .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
    .topbar .brand { font-size: 15px; }
    .topbar .brand img { width: 36px !important; height: 36px !important; max-width: 36px; max-height: 36px; flex-basis: 36px; }
    .topbar .brand { flex: 1 1 100%; }
    .topbar .user-info { width: 100%; justify-content: flex-end; gap: 6px; }
    .topbar > .search-bar { width: 100%; flex-basis: 100%; margin: 0; }
    .topbar .user-info > span:first-child { display: none; }
    .topbar .user-info .btn { min-height: 36px; padding: 7px 10px; }
    .container { margin: 18px auto; padding: 0 12px; }
    .card { padding: 16px; border-radius: 10px; }
    h2 { font-size: 20px; }
    .toolbar-actions { width: 100%; margin-left: 0; justify-content: flex-start; flex-wrap: wrap; }
    .login-wrap { padding: 16px; }
    .login-box { padding: 24px 20px; }
    table.filelist { display: block; overflow-x: auto; white-space: nowrap; }
    .profession-user-heading, .profession-files li { align-items: flex-start; flex-direction: column; }
    .profession-files { padding-left: 0; }
    .profession-files .actions { margin-left: 0; }
    .search-bar { align-items: stretch; flex-direction: column; }
    .profession-summary { grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
    .profession-summary div { padding: 12px 10px; }
    .profession-summary strong { font-size: 20px; }
    .profession-card-header { grid-template-columns: 18px minmax(0, 1fr) auto; align-items: flex-start; padding: 14px; }
    .profession-title { gap: 9px; }
    .profession-icon { flex-basis: 36px; width: 36px; height: 36px; font-size: 19px; }
    .profession-content { padding: 0 14px 4px; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
    .modal { max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 18px; }
}

@media (max-width: 380px) {
    .topbar .user-info .btn { font-size: 11px; padding-left: 8px; padding-right: 8px; }
    .profession-summary strong { font-size: 18px; }
    .profession-summary span { font-size: 11px; }
}
