:root {
    color-scheme: light;
    --background: #fbfbfb;
    --surface: #fff;
    --ink: #262626;
    --primary: #262626;
    --on-primary: #fff;
    --muted: #5c5a60;
    --border: #d7d5da;
    --soft: #ebe9ed;
    --accent: #8f251d;
    --table-heading: #f7f7f7;
    --success-surface: #e7f4e9;
    --success-text: #15532a;
    --danger-surface: #fbe9e7;
    --danger-text: #761b15;
    --required-mark: #b42318;
    font-family: "Noto Sans Georgian", "DejaVu Sans", sans-serif;
    color: var(--ink);
    background: var(--background);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #181818;
    --surface: #222;
    --ink: #f4f4f4;
    --primary: #262626;
    --muted: #bbb;
    --border: #424242;
    --soft: #303030;
    --accent: #f3988e;
    --table-heading: #2b2b2b;
    --success-surface: #21382b;
    --success-text: #b5e8c6;
    --danger-surface: #492928;
    --danger-text: #ffd0c9;
    --required-mark: #ff9388;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 2vw, 1.8rem); }
h2 { font-size: 1.12rem; }
p, small, footer { color: var(--muted); }
p { line-height: 1.6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { padding: 24px 14px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 5px; width: fit-content; }
.brand img { width: 154px; height: 38px; object-fit: contain; object-position: left center; }
.brand small { padding-left: 4px; font-size: .75rem; }
[data-theme="dark"] .brand img { background: #fff; border-radius: 6px; padding: 4px 6px; }

.side-nav { display: grid; gap: 5px; margin-top: 34px; align-content: start; }
.nav-group { position: relative; min-width: 0; }
.nav-row { display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 9px 12px; border-radius: 7px; font-size: .875rem; }
.side-nav summary { list-style: none; font-weight: 650; }
.side-nav summary::-webkit-details-marker { display: none; }
.side-nav summary::after { content: ''; width: 7px; height: 7px; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.nav-group[open] > summary::after { transform: rotate(45deg); }
.nav-row:hover, .nav-group[open] > summary, .nav-group[data-current-group] > summary { background: var(--soft); }
.nav-row[aria-current="page"] { background: var(--primary); color: var(--on-primary); font-weight: 700; }
[data-theme="dark"] .nav-row[aria-current="page"] { outline: 1px solid #666; outline-offset: -1px; }
.nav-icon { flex: 0 0 18px; text-align: center; font-size: 1rem; }
.nav-children { display: grid; gap: 4px; padding: 4px 0 0 16px; margin: 0; list-style: none; }
.nav-children .nav-row { min-height: 39px; }

[data-sidebar="collapsed"] .shell { grid-template-columns: 72px minmax(0, 1fr); }
[data-sidebar="collapsed"] .sidebar { padding-inline: 10px; }
[data-sidebar="collapsed"] .sidebar .brand img { width: 100%; height: 25px; object-position: center; }
[data-sidebar="collapsed"] .sidebar .brand small,
[data-sidebar="collapsed"] .nav-label,
[data-sidebar="collapsed"] .side-nav summary::after { display: none; }
[data-sidebar="collapsed"] .side-nav > .nav-row,
[data-sidebar="collapsed"] .side-nav summary { justify-content: center; }
[data-sidebar="collapsed"] .nav-children { position: absolute; z-index: 5; top: 0; left: calc(100% + 8px); min-width: 208px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 5px 12px #0002; }

.workspace { display: flex; flex-direction: column; min-width: 0; width: 100%; padding: 22px clamp(14px, 1.7vw, 32px) 16px; }
.topbar { display: flex; justify-content: flex-end; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--surface); padding: 15px 24px; border: 1px solid var(--border); border-radius: 10px; min-height: 74px; }
.layout-control { width: 40px; min-height: 40px; flex: 0 0 40px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 0; font-size: 1rem; }
.layout-control:hover { background: var(--soft); filter: none; }
.account { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: .9rem; }
.workspace main { flex: 1; padding-top: 38px; }
footer { margin-top: 48px; font-size: .85rem; }
.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.heading p { margin-top: 8px; }
.spaced { margin-top: 32px; }

.cards { display: grid; gap: clamp(14px, 1.7vw, 32px); }
.role-grid, .settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.security-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.card h2 { margin-bottom: 22px; }
.card p + p { margin-top: 12px; }
.card label + p { margin-top: 12px; }
.rounded { padding: clamp(20px, 2vw, 38px); border-radius: 28px; }
.role-title { display: flex; align-items: center; gap: 14px; justify-content: space-between; min-height: 46px; }
.role-title span { background: var(--soft); min-width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.tabs a { padding: 12px 15px; border: 1px solid var(--border); border-radius: 10px; font-size: .9rem; background: var(--surface); }
.tabs .active { background: var(--primary); color: var(--on-primary); }

form { margin: 0; }
.fields { display: grid; gap: 16px; }
.fields > button { justify-self: start; }
label { display: grid; gap: 7px; font-size: .88rem; }
input, select, button, .button { font: inherit; }
input, select { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; min-height: 42px; min-width: 0; padding: 8px 10px; color: var(--ink); }
label input, label select { width: 100%; }
input[type=file] { max-width: 100%; }
input[type=checkbox] { width: auto; min-height: auto; accent-color: var(--ink); }
fieldset { border: 1px solid var(--border); border-radius: 9px; }
.check { display: flex; align-items: center; margin: 6px 0; }
button, .button { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border: 0; background: var(--primary); color: var(--on-primary); padding: 10px 15px; min-height: 42px; border-radius: 9px; font-size: .88rem; font-weight: 650; }
button:hover, .button:hover { filter: brightness(1.18); }
.secondary { background: var(--soft); color: var(--ink); }
.danger { background: var(--danger-surface); color: var(--danger-text); }
summary { cursor: pointer; font-size: .88rem; }
.editor-fields { margin: 12px 0; min-width: min(240px, 100%); }
.editor { max-width: 100%; }
.table-card { padding: 0; }
.table-tools { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px; padding: 16px 20px; }
.inline-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; flex: 1; }
.inline-fields label { display: flex; align-items: center; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; text-align: left; }
th, td { padding: 14px 20px; border-top: 1px solid var(--soft); vertical-align: top; }
th { background: var(--table-heading); white-space: nowrap; }
.pagination { display: flex; gap: 12px; justify-content: flex-end; align-items: center; padding: 14px 20px; }
.pagination a { padding: 6px 10px; background: var(--soft); border-radius: 6px; }

.preview { max-width: 100%; max-height: 100px; object-fit: contain; margin-bottom: 15px; }
.profile-header { padding: 0; margin-bottom: 28px; overflow: hidden; }
.profile-cover { position: relative; min-height: 200px; display: grid; align-items: center; justify-items: end; background: var(--primary); }
.cover-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-brand { width: min(36%, 340px); margin-right: 8%; }
.profile-identity { position: relative; padding: 0 30px 24px; display: flex; gap: 18px; align-items: end; }
.avatar { width: clamp(78px, 10vw, 150px); aspect-ratio: 1; object-fit: cover; margin-top: -40px; }
.avatar-fallback { display: grid; place-items: center; background: var(--soft); color: var(--ink); font-size: 2.5rem; }
dl { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; row-gap: 14px; margin: 0; font-size: .88rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }

.notice { margin-bottom: 16px; padding: 12px 16px; border-radius: 8px; background: var(--success-surface); color: var(--success-text); }
.notice.error { background: var(--danger-surface); color: var(--danger-text); }
.auth-basic { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-form { width: min(100%, 420px); padding: clamp(24px, 5vw, 36px); }
.auth-form > .brand { display: flex; margin: 0 auto 30px; align-items: center; }
.auth-form > .brand img { object-position: center; }
.auth-banner { display: block; width: 100%; max-height: 140px; object-fit: contain; margin-bottom: 20px; }
.auth-bypass { margin-top: 18px; }
.auth-form h1 { margin-bottom: 20px; }
.auth-form .fields > button { justify-self: stretch; }
.qr { width: min(200px, 100%); margin: 12px auto; }
.qr svg { width: 100%; height: auto; }
.code-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 15px 0; list-style: none; }

@media (max-width: 1080px) {
    .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px 14px; }
    .side-nav { margin-top: 14px; }
    [data-sidebar="collapsed"] .sidebar { border-right: 1px solid var(--border); border-bottom: 0; }
    [data-sidebar="collapsed"] .shell { grid-template-columns: 56px minmax(0, 1fr); }
    [data-sidebar="collapsed"] .sidebar { padding-inline: 7px; }
    .topbar { padding: 12px; }
}
@media (max-width: 570px) {
    .role-grid, .settings-grid, .security-grid { grid-template-columns: 1fr; }
    .profile-cover { min-height: 130px; }
    .profile-identity { padding-inline: 16px; }
    .account { margin-left: 0; }
    th, td { padding-inline: 12px; }
}

.sidebar-brand { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-inline: 8px; }
.sidebar-brand .layout-control { flex-basis: 32px; width: 32px; min-height: 34px; }
[data-sidebar="collapsed"] .sidebar-brand { flex-direction: column; padding: 0; }
[data-sidebar="collapsed"] .sidebar-brand .layout-control { flex-basis: auto; }
[data-sidebar="collapsed"] .sidebar-brand .brand { width: 100%; min-height: 38px; justify-content: center; }

.account-menu { position: relative; }
.account-trigger { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; list-style: none; }
.account-trigger::-webkit-details-marker { display: none; }
.account-trigger:hover, .account-menu[open] .account-trigger { background: var(--soft); }
.account-popover { position: absolute; z-index: 10; inset: calc(100% + 8px) 0 auto auto; display: grid; gap: 11px; width: min(250px, calc(100vw - 48px)); padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px #0002; }
.account-identity { display: flex; align-items: center; gap: 10px; padding: 2px 0 11px; border-bottom: 1px solid var(--border); }
.account-identity strong, .account-identity small { display: block; overflow-wrap: anywhere; }
.account-identity small { margin-top: 3px; }
.account-avatar { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--soft); font-weight: 700; }
.account-action { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 7px 8px; border-radius: 6px; }
.account-action:hover { background: var(--soft); filter: none; }
.account-signout { padding-top: 8px; border-top: 1px solid var(--border); }
.account-signout .account-action { width: 100%; background: var(--danger-surface); color: var(--danger-text); justify-content: flex-start; }

.admin-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(100%, 460px); max-width: none; height: 100dvh; max-height: none; padding: 0; overflow: hidden; background: var(--surface); color: var(--ink); border: 0; border-inline-start: 1px solid var(--border); }
.admin-drawer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.admin-drawer::backdrop { background: rgb(0 0 0 / 42%); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-body { overflow-y: auto; overscroll-behavior: contain; padding: 18px 22px 28px; }
.drawer-footer { display: flex; justify-content: flex-end; gap: 10px; margin: 0; padding: 14px 22px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.drawer-body .editor-fields { margin: 0; }



.required-mark { color: var(--required-mark); }
.preference-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preference-buttons { display: flex; gap: 5px; }
.preference-buttons .layout-control { width: 34px; min-height: 34px; flex-basis: 34px; }
.preference-buttons .layout-control[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.drawer-actions { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }

.image-upload { min-width: 0; }
.upload-zone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 20px 12px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--background);
    text-align: center;
}
.upload-zone input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.upload-zone:hover, .upload-zone.is-dragging { border-color: var(--accent); background: var(--soft); }
.upload-zone:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.upload-icon { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 1.15rem; }
.upload-instructions { line-height: 1.5; }
.upload-selection { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 9px; }
.upload-selection[hidden] { display: none; }
.upload-selection img { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; background: var(--soft); }
.upload-selection span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .82rem; }
.upload-selection .layout-control { flex-basis: 32px; width: 32px; min-height: 32px; }
.upload-status:not(:empty) { margin-top: 6px; color: var(--muted); font-size: .78rem; }
