:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #dfe7f0;
    --line-strong: #c8d6e5;
    --text: #1d2939;
    --muted: #667085;
    --primary: #016e9f;
    --primary-dark: #084c68;
    --primary-soft: #e8f3fb;
    --accent: #0d6efd;
    --danger: #b42318;
    --ok: #0f7b4f;
    --shadow: 0 12px 30px rgba(16, 24, 40, .07);
    --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    min-height: 60px;
    background: linear-gradient(0deg, var(--primary-dark), var(--primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 22px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .1px;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 8px;
    background: rgba(255, 255, 255, .14);
    font-size: 13px;
}
.nav {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 11px;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    opacity: .94;
}
.nav a:hover {
    background: rgba(255, 255, 255, .13);
    text-decoration: none;
}
.wrap {
    max-width: 1180px;
    margin: 28px auto;
    padding: 0 18px;
}
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-3 { grid-column: span 3; }
.col-12 { grid-column: span 12; }
.panel,
.drive-directory,
.drive-files {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel { padding: 22px; }
.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
h1, h2, h3 { margin: 0 0 14px; font-weight: 650; color: #26364a; letter-spacing: 0; }
h1 { font-size: 27px; line-height: 1.15; }
h2 { font-size: 19px; line-height: 1.2; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.kicker,
.eyebrow {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.notice {
    margin: 14px 0 18px;
    padding: 14px 16px;
    border: 1px solid #bfd3ea;
    border-radius: 8px;
    background: #f0f6fc;
}
.notice ol { margin: 8px 0 10px 20px; padding: 0; }
.notice li { margin: 5px 0; line-height: 1.4; }
.notice p { margin: 8px 0 0; }
code { font-family: Consolas, Monaco, monospace; font-size: .95em; }
.form-row { margin-bottom: 14px; }
label {
    display: block;
    margin-bottom: 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}
small { display: block; color: var(--muted); margin-top: 6px; line-height: 1.35; }
input, select, textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    padding: 10px 11px;
    font: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 110px; resize: vertical; }
.config-textarea { min-height: 220px; }
.config-textarea.compact { min-height: 130px; }
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 5px 12px rgba(1, 110, 159, .18);
}
.btn:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn.secondary {
    background: #fff;
    color: #26364a;
    border-color: var(--line-strong);
    box-shadow: none;
}
.btn.secondary:hover { background: var(--panel-soft); }
.btn.danger { background: var(--danger); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.flash {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
    background: #e7f7ef;
    color: var(--ok);
    border: 1px solid #b8e3cc;
    font-weight: 600;
}
.flash.err {
    background: #fff0f0;
    color: var(--danger);
    border-color: #ffd0d0;
}
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.table th,
.table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 11px;
    text-align: left;
    vertical-align: top;
}
.table th {
    background: #f7f9fc;
    color: #475467;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.table tr:last-child td { border-bottom: 0; }
.table-context {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4px 10px;
    background: var(--primary-soft);
    color: #075985;
    font-size: 12px;
    font-weight: 800;
}
.badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}
.folder-list { display: grid; gap: 8px; }
.folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.login {
    max-width: 440px;
    margin: 8vh auto;
    padding: 0 18px;
}
.login .panel {
    border-top: 4px solid var(--primary);
}
.login h1 {
    display: flex;
    align-items: center;
    gap: 10px;
}
.login .brand-mark {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.drive-page {
    min-height: 100vh;
    background: #f4f7fb;
}
.drive-shell {
    width: calc(100% - 24px);
    min-height: calc(100vh - 60px);
    margin: 0 auto;
    padding: 24px 0 34px;
}
.drive-hero {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: flex-end;
    padding: 24px 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}
.drive-hero h1 {
    margin-bottom: 8px;
    font-size: clamp(28px, 3.2vw, 42px);
    line-height: 1.05;
}
.drive-hero p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    font-size: 16px;
}
.drive-account {
    min-width: 280px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}
.drive-account span,
.drive-metrics span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.drive-account strong {
    display: block;
    margin-top: 6px;
    overflow-wrap: anywhere;
}
.drive-refresh {
    width: 100%;
    margin-top: 12px;
}
.drive-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin: 18px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}
.drive-search {
    display: flex;
    flex: 1 1 auto;
    gap: 10px;
    align-items: center;
}
.drive-search input[type="search"] {
    min-height: 44px;
    border-color: var(--line-strong);
    background: #fbfdff;
}
.drive-nav-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
    align-items: center;
}
.drive-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0;
}
.drive-metrics div {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(16, 24, 40, .05);
}
.drive-metrics strong {
    display: block;
    font-size: 26px;
    line-height: 1.1;
}
.drive-layout {
    display: grid;
    grid-template-columns: minmax(420px, 585px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.drive-directory { padding: 22px; }
.drive-files {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 96px);
    overflow: auto;
    padding: 20px;
}
.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}
.section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin: 0; color: var(--muted); }
.premium-folder-list,
.file-list { display: grid; gap: 10px; }
.premium-folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 78px;
    padding: 14px;
    border: 1px solid #e4eaf2;
    border-radius: 8px;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.premium-folder-item:hover {
    border-color: #a9c6e6;
    box-shadow: 0 12px 26px rgba(16, 24, 40, .08);
    transform: translateY(-1px);
}
.drive-directory .premium-folder-item {
    align-items: center;
    flex-direction: row;
    gap: 14px;
}
.drive-directory .folder-actions {
    width: auto;
}
.drive-directory .folder-actions .btn {
    flex: 0 0 auto;
    min-width: 0;
}
.folder-main {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    gap: 13px;
    align-items: center;
    color: var(--text);
}
.folder-main:hover { text-decoration: none; }
.folder-main strong,
.file-row strong {
    display: block;
    overflow-wrap: anywhere;
}
.folder-main small,
.file-row small { margin-top: 4px; }
.folder-mark,
.file-mark,
.icon-tile {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--primary-soft);
    border: 1px solid #cfe4f5;
    position: relative;
}
.folder-mark::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 13px;
    width: 24px;
    height: 16px;
    border-radius: 3px;
    background: var(--primary);
}
.folder-mark::after {
    content: "";
    position: absolute;
    left: 11px;
    top: 9px;
    width: 12px;
    height: 7px;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
}
.folder-mark.shared { background: #e8f7ef; border-color: #c8ebd7; }
.folder-mark.shared::before,
.folder-mark.shared::after { background: var(--ok); }
.file-mark {
    width: 34px;
    height: 38px;
    background: #f2f4f7;
    border-color: #d0d5dd;
}
.file-mark::before {
    content: "";
    position: absolute;
    inset: 7px 8px;
    border: 2px solid #667085;
    border-top-width: 5px;
    border-radius: 2px;
}
.folder-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    align-items: center;
}
.btn.compact {
    min-height: 38px;
    padding: 9px 12px;
    white-space: nowrap;
}
.file-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #e7edf4;
    border-radius: 8px;
    background: #fff;
}
.file-row:last-child { border-bottom: 0; }
.file-main {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    gap: 12px;
    align-items: center;
}
.file-main > span:last-child {
    min-width: 0;
}
.file-action {
    flex: 0 0 auto;
}
.empty-state {
    display: grid;
    gap: 5px;
    padding: 28px;
    border: 1px dashed #c8d4e2;
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
}
.empty-state strong { color: var(--text); }
.empty-state.slim { padding: 20px; }
.draft-result {
    width: 100%;
    max-height: 68vh;
    overflow: auto;
    margin: 18px 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: #1d2939;
    font: 14px/1.6 Consolas, "Courier New", monospace;
    white-space: pre-wrap;
}

.ico {
    display: inline-block;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    position: relative;
}
.ico::before,
.ico::after {
    content: "";
    position: absolute;
    box-sizing: border-box;
}
.ico-home::before {
    left: 3px;
    top: 7px;
    width: 12px;
    height: 9px;
    border: 2px solid currentColor;
    border-top: 0;
    border-radius: 1px;
}
.ico-home::after {
    left: 4px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-top: 2px solid currentColor;
    transform: rotate(45deg);
}
.ico-cloud::before {
    left: 2px;
    top: 8px;
    width: 14px;
    height: 7px;
    border: 2px solid currentColor;
    border-top: 0;
    border-radius: 0 0 8px 8px;
}
.ico-cloud::after {
    left: 5px;
    top: 4px;
    width: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 999px;
    background: transparent;
}
.ico-admin::before {
    left: 3px;
    top: 4px;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 999px;
}
.ico-admin::after {
    left: 7px;
    top: 1px;
    width: 4px;
    height: 16px;
    border-top: 3px solid currentColor;
    border-bottom: 3px solid currentColor;
}
.ico-logout::before {
    left: 2px;
    top: 4px;
    width: 8px;
    height: 10px;
    border: 2px solid currentColor;
    border-right: 0;
}
.ico-logout::after {
    right: 1px;
    top: 5px;
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-top: 2px solid currentColor;
    transform: rotate(45deg);
}
.ico-search::before {
    left: 2px;
    top: 2px;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-radius: 999px;
}
.ico-search::after {
    right: 2px;
    bottom: 2px;
    width: 7px;
    height: 2px;
    background: currentColor;
    transform: rotate(45deg);
}
.ico-save::before {
    inset: 2px;
    border: 2px solid currentColor;
    border-radius: 2px;
}
.ico-save::after {
    left: 5px;
    bottom: 4px;
    width: 8px;
    height: 5px;
    border: 2px solid currentColor;
    background: currentColor;
}
.ico-plus::before {
    left: 8px;
    top: 3px;
    width: 2px;
    height: 12px;
    background: currentColor;
}
.ico-plus::after {
    left: 3px;
    top: 8px;
    width: 12px;
    height: 2px;
    background: currentColor;
}
.ico-back::before {
    left: 4px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}
.ico-open::before {
    left: 2px;
    top: 5px;
    width: 13px;
    height: 10px;
    border: 2px solid currentColor;
    border-radius: 2px;
}
.ico-open::after {
    right: 2px;
    top: 2px;
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
}
.ico-link::before {
    left: 2px;
    top: 5px;
    width: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 999px;
}
.ico-link::after {
    right: 2px;
    top: 5px;
    width: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 999px;
}
.ico-refresh::before {
    left: 3px;
    top: 3px;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
}
.ico-refresh::after {
    right: 2px;
    top: 2px;
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(18deg);
}
.ico-user::before {
    left: 6px;
    top: 2px;
    width: 7px;
    height: 7px;
    border: 2px solid currentColor;
    border-radius: 999px;
}
.ico-user::after {
    left: 3px;
    bottom: 2px;
    width: 12px;
    height: 7px;
    border: 2px solid currentColor;
    border-radius: 999px 999px 2px 2px;
}
.ico-tasks::before {
    left: 3px;
    top: 3px;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 3px;
}
.ico-tasks::after {
    left: 6px;
    top: 7px;
    width: 8px;
    height: 5px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
}
.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.multiadv-selector {
    margin: 18px 0 22px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}
.multiadv-result-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin: 22px 0 14px;
}

@media (max-width: 820px) {
    .col-3, .col-4, .col-6, .col-8, .col-9 { grid-column: span 12; }
    .topbar {
        height: auto;
        padding: 14px 18px;
        align-items: flex-start;
        flex-direction: column;
    }
    .nav { width: 100%; }
    .nav a { flex: 1 1 auto; justify-content: center; }
    .panel-header,
    .drive-hero,
    .section-heading,
    .premium-folder-item {
        align-items: stretch;
        flex-direction: column;
    }
    .drive-shell { width: calc(100% - 20px); padding-top: 18px; }
    .drive-toolbar,
    .drive-search,
    .drive-nav-actions {
        align-items: stretch;
        flex-direction: column;
    }
    .drive-nav-actions .btn,
    .drive-search .btn { width: 100%; }
    .drive-account { min-width: 0; }
    .drive-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .drive-layout { grid-template-columns: 1fr; }
    .drive-files {
        position: static;
        max-height: none;
    }
    .folder-actions { width: 100%; }
    .folder-actions .btn { flex: 1; }
    .table { display: block; overflow-x: auto; }
}
