:root {
    --topbar-height: 60px;
    --sidebar-width: 236px;
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-soft: #f1f5f9;
    --surface-hover: #eaf2ff;
    --border: #dbe3ef;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --primary: #0b73f6;
    --primary-dark: #075bc3;
    --primary-soft: #e4f0ff;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --row-height: 43px;
}

html[data-theme="dark"] {
    --bg: #0b1120;
    --surface: #111827;
    --surface-soft: #162032;
    --surface-hover: #172a46;
    --border: #243244;
    --border-strong: #334155;
    --text: #e5edf8;
    --text-soft: #cbd5e1;
    --muted: #94a3b8;
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --primary-soft: #102a4a;
    --danger: #f87171;
    --danger-soft: #3a1519;
    --success: #4ade80;
    --success-soft: #10351f;
    --warning: #fbbf24;
    --warning-soft: #3b2a0a;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

body.is-connected {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    padding: 2px 6px;
    border-radius: 7px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 12px;
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input,
select {
    height: 39px;
    padding: 0 12px;
}

textarea {
    padding: 10px 12px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

label {
    display: grid;
    gap: 7px;
    color: var(--text-soft);
    font-weight: 600;
}

label > input,
label > select,
label > textarea {
    font-weight: 500;
}

.muted,
.form-hint {
    color: var(--muted);
}

.form-hint {
    margin: 0;
    font-size: 13px;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.stacked-form {
    display: grid;
    gap: 16px;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 600;
}

.checkbox input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.button,
.icon-button,
.row-action,
.sidebar-add,
.sidebar-delete {
    border: 0;
    cursor: pointer;
    user-select: none;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
    transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.button:hover,
.icon-button:hover,
.row-action:hover,
.sidebar-add:hover,
.sidebar-delete:hover {
    transform: translateY(-1px);
}

.button.primary {
    background: var(--primary);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

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

.button.ghost,
.button.icon-only {
    border-color: var(--border);
    background: transparent;
}

.button.icon-only {
    width: 40px;
    padding: 0;
    font-size: 16px;
    font-weight: 900;
}

.button.small {
    min-height: 31px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
}

.button.danger {
    background: var(--danger);
    color: #ffffff;
}

.icon-button {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-soft);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 800;
}

.alert {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    padding: 12px 14px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.alert.success {
    color: var(--success);
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 24%, var(--border));
}

.alert.error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 25%, var(--border));
}

.alert.warning {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: color-mix(in srgb, var(--warning) 28%, var(--border));
}

.flash-stack {
    position: fixed;
    top: calc(var(--topbar-height) + 12px);
    right: 18px;
    z-index: 80;
    width: min(520px, calc(100vw - 36px));
    display: grid;
    gap: 10px;
}

.inline-alert {
    margin: 14px 18px;
}

.app-topbar {
    height: var(--topbar-height);
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) auto;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 60;
}

.app-brand {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-right: 1px solid var(--border);
    font-weight: 800;
}

.brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #ffffff;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.brand-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-connection {
    justify-self: end;
    min-width: 0;
    max-width: min(580px, 58vw);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--success) 22%, var(--border));
    background: color-mix(in srgb, var(--success-soft) 70%, transparent);
    color: var(--success);
    font-weight: 800;
    font-size: 12px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.endpoint-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.region-text {
    color: var(--muted);
    font-weight: 700;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-right: 14px;
}

.theme-toggle #themeToggleIcon {
    font-size: 0;
}

.theme-toggle #themeToggleIcon::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 999px;
    display: block;
    border: 2px solid currentColor;
    box-shadow: inset -4px -2px 0 currentColor;
}

html[data-theme="dark"] .theme-toggle #themeToggleIcon::before {
    box-shadow: none;
    background: currentColor;
}

.app-page {
    height: calc(100vh - var(--topbar-height));
}

.dashboard-shell {
    height: 100%;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    overflow: hidden;
}

.buckets-panel {
    min-width: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
    padding: 18px 14px;
}

.buckets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 16px;
    padding: 0 0 0 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.16em;
}

.sidebar-add {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 18px;
    line-height: 1;
}

.sidebar-empty {
    margin: 10px 2px;
    font-size: 13px;
}

.bucket-list {
    list-style: none;
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 0;
}

.bucket-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24px;
    align-items: center;
    min-height: 40px;
    border-radius: 10px;
    color: var(--text-soft);
    transition: background 0.16s ease, color 0.16s ease;
}

.bucket-item:hover,
.bucket-item.active {
    background: var(--surface-hover);
    color: var(--primary);
}

.bucket-item a {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 7px 9px 10px;
}

.bucket-icon {
    width: 17px;
    height: 13px;
    flex: 0 0 auto;
    border-radius: 3px;
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    position: relative;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

.bucket-icon::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 2px;
    width: 8px;
    height: 4px;
    border-radius: 3px 3px 0 0;
    background: #7dd3fc;
}

.bucket-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.sidebar-delete {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    opacity: 0;
}

.bucket-item:hover .sidebar-delete,
.bucket-item.active .sidebar-delete {
    opacity: 1;
}

.sidebar-delete:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.delete-bucket-form {
    margin: 0;
}

.workspace {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.workspace-empty {
    height: 100%;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 14px;
    text-align: center;
    padding: 32px;
}

.empty-illustration {
    width: 74px;
    height: 74px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 900;
    letter-spacing: 0.08em;
}

.workspace-empty h1 {
    margin: 0;
    font-size: 28px;
}

.workspace-empty p {
    margin: 0;
    color: var(--muted);
}

.empty-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.workspace-header {
    min-height: 82px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.workspace-heading {
    min-width: 0;
}

.breadcrumb-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 5px;
}

.breadcrumb-line a {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.breadcrumb-line a:hover {
    color: var(--primary);
}

.workspace-title-row {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
}

.workspace-title-row h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.15;
}

.workspace-title-row p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.workspace-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    min-width: 0;
}

.search-form {
    width: min(350px, 28vw);
    min-width: 190px;
}

.search-form input[type="search"] {
    height: 40px;
    border-radius: 10px;
    padding-left: 14px;
    background: var(--surface-soft);
}

.details-strip {
    margin: 12px 18px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: 12px;
}

.details-strip dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.details-strip dt {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 900;
}

.details-strip dd {
    margin: 4px 0 0;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.details-warnings {
    margin-top: 10px;
    color: var(--warning);
    font-size: 13px;
}

.objects-panel {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.objects-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: 13px;
}

.objects-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 38px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 10px;
    font-weight: 900;
    text-align: left;
}

.objects-table tbody td {
    height: var(--row-height);
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    background: var(--surface);
}

.object-row:hover td {
    background: var(--surface-hover);
}

.select-col {
    width: 48px;
    text-align: center;
}

.select-col input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.name-col {
    width: auto;
}

.size-col {
    width: 120px;
    color: var(--text-soft);
    white-space: nowrap;
}

.date-col {
    width: 170px;
    color: var(--muted);
    white-space: nowrap;
}

.actions-col {
    width: 170px;
    text-align: right;
    white-space: nowrap;
}

.file-name-link {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.file-name-link strong,
.file-name-link small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-name-link strong {
    font-weight: 800;
}

.file-name-link small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 1px;
}

.file-name-link:not(.no-link):hover strong {
    color: var(--primary);
}

.file-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--surface-soft);
    position: relative;
}

.file-icon::before {
    font-size: 14px;
    font-weight: 900;
    color: var(--muted);
}

.file-icon.folder {
    background: #fff3d6;
}

.file-icon.folder::before {
    content: "";
    width: 16px;
    height: 12px;
    border-radius: 3px;
    background: #f59e0b;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.file-icon.file {
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.file-icon.file::before {
    content: "";
    width: 13px;
    height: 16px;
    border-radius: 3px;
    border: 2px solid var(--primary);
    background: transparent;
}

.file-icon.up::before {
    content: "..";
}

.row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: 4px;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
    font-size: 14px;
}

.row-action:hover {
    background: var(--surface-soft);
    color: var(--primary);
}

.row-more {
    display: inline-block;
    position: relative;
}

.row-more summary {
    list-style: none;
}

.row-more summary::-webkit-details-marker {
    display: none;
}

.row-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 30;
    width: 340px;
    max-width: min(340px, calc(100vw - 36px));
    display: grid;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: left;
}

.mini-form {
    display: grid;
    gap: 8px;
    margin: 0;
}

.mini-form label {
    font-size: 12px;
}

.delete-form {
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.empty-table {
    height: 140px !important;
    text-align: center;
    color: var(--muted);
}

.metadata-table {
    width: 100%;
    border-collapse: collapse;
}

.metadata-table th,
.metadata-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    text-align: left;
}

.metadata-table th {
    width: 180px;
    color: var(--muted);
    font-size: 12px;
}

.metadata-table td {
    overflow-wrap: anywhere;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
}

.modal {
    width: min(620px, 100%);
    max-height: min(86vh, 760px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.compact-modal {
    width: min(460px, 100%);
}

.link-modal {
    width: min(720px, 100%);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.modal-body,
.modal-form,
.link-result {
    padding: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.compact-actions {
    justify-content: flex-start;
    padding: 0;
    margin-top: 10px;
}

.choice-card {
    margin: 0;
    padding: 0;
    border: 0;
    display: grid;
    gap: 10px;
}

.choice-card legend {
    margin-bottom: 4px;
    color: var(--text-soft);
    font-weight: 800;
}

.radio-card {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    cursor: pointer;
}

.radio-card input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
}

.radio-card strong,
.radio-card small {
    display: block;
}

.radio-card small {
    color: var(--muted);
    font-weight: 500;
    margin-top: 2px;
}

.link-options {
    display: grid;
    gap: 10px;
}

.link-result {
    border-top: 1px solid var(--border);
    background: var(--surface-soft);
}

.guest-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(300px, 420px);
    gap: 22px;
    align-content: center;
    justify-content: center;
    padding: 34px;
}

.card,
.connect-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    padding: 24px;
}

.connect-card h1,
.card h2 {
    margin-top: 0;
}

.examples {
    display: grid;
    gap: 8px;
    padding-left: 18px;
}

.actions {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 210px;
    }

    .workspace-header {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .workspace-tools {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .search-form {
        width: min(100%, 420px);
    }

    .actions-col {
        width: 170px;
    }
}

@media (max-width: 820px) {
    body.is-connected {
        overflow: auto;
    }

    .app-topbar {
        grid-template-columns: 1fr auto;
    }

    .app-brand {
        border-right: 0;
    }

    .topbar-connection {
        display: none;
    }

    .app-page {
        height: auto;
        min-height: calc(100vh - var(--topbar-height));
    }

    .dashboard-shell {
        height: auto;
        min-height: calc(100vh - var(--topbar-height));
        grid-template-columns: 1fr;
    }

    .buckets-panel {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        max-height: 240px;
    }

    .bucket-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .objects-panel {
        min-height: 520px;
    }

    .date-col {
        width: 140px;
    }

    .actions-col {
        width: 170px;
    }

    .guest-page {
        grid-template-columns: 1fr;
        padding: 18px;
    }
}

@media (max-width: 640px) {
    .brand-text,
    .size-col,
    .date-col {
        display: none;
    }

    .app-brand {
        padding-left: 12px;
    }

    .workspace-header {
        padding: 12px;
    }

    .workspace-tools {
        gap: 7px;
    }

    .search-form {
        width: 100%;
        min-width: 0;
        flex-basis: 100%;
    }

    .select-col {
        width: 34px;
    }

    .actions-col {
        width: 140px;
    }

    .row-action {
        width: 28px;
        height: 28px;
        margin-left: 2px;
        font-size: 13px;
    }

    .modal-backdrop {
        padding: 10px;
        place-items: end center;
    }

    .modal {
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
    }
}

/* Enhanced UI fixes and additions */
.button,
.icon-button,
.row-action,
.sidebar-add,
.sidebar-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
}

.icon-button,
.button.icon-only,
.sidebar-add,
.sidebar-delete {
    flex: 0 0 auto;
}

.alert {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.alert.is-dismissing {
    opacity: 0;
    transform: translateY(-6px);
}

.alert-message {
    min-width: 0;
    overflow-wrap: anywhere;
}

.alert-close {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: currentColor;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.65;
}

.alert-close:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 12%, transparent);
}

body.is-guest .flash-stack {
    top: 18px;
}

.bulk-form {
    margin: 0;
}

.bulk-toolbar {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--primary-soft) 46%, var(--surface));
}

.bulk-toolbar[hidden] {
    display: none !important;
}

.bulk-summary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    font-weight: 800;
    white-space: nowrap;
}

.bulk-summary strong {
    min-width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-size: 12px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.row-action.text-action {
    width: auto;
    min-width: 40px;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 800;
}

.actions-col {
    width: 250px;
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.drop-zone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 28px 18px;
    border: 1.5px dashed var(--border-strong);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-soft) 74%, var(--surface));
    text-align: center;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: translateY(-1px);
}

.drop-zone-icon {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 24px;
    font-weight: 900;
}

.drop-zone-copy {
    display: grid;
    gap: 4px;
    color: var(--text-soft);
}

.drop-zone-copy strong {
    color: var(--text);
    font-size: 16px;
}

.text-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 900;
    cursor: pointer;
}

.text-button:hover {
    text-decoration: underline;
}

.upload-file-list {
    width: min(100%, 520px);
    max-height: 130px;
    overflow: auto;
    display: grid;
    gap: 6px;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.upload-file-list li {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.guest-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 34px;
    background:
        radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 28%),
        radial-gradient(circle at 78% 12%, color-mix(in srgb, #7c3aed 10%, transparent), transparent 24%),
        var(--bg);
}

.connect-shell {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(360px, 520px) minmax(280px, 420px);
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.connect-card-modern,
.connect-info-card {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.connect-card-modern {
    padding: 28px;
}

.connect-info-card {
    padding: 26px;
}

.connect-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.connect-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-mark.big {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 13px;
}

.connect-brand h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
}

.connect-brand p {
    margin: 6px 0 0;
    color: var(--muted);
    max-width: 390px;
}

.connect-form {
    gap: 17px;
}

.field-block small {
    color: var(--muted);
    font-weight: 500;
}

.form-grid.two-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.preset-section {
    display: grid;
    gap: 10px;
}

.preset-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 900;
}

.preset-heading small {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
}

.endpoint-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.endpoint-preset {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    font-weight: 900;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.endpoint-preset:hover,
.endpoint-preset.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    transform: translateY(-1px);
}

.extra-options {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-soft) 72%, var(--surface));
    overflow: hidden;
}

.extra-options summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    cursor: pointer;
    color: var(--text-soft);
    font-weight: 900;
}

.extra-options summary small {
    color: var(--muted);
    font-weight: 700;
}

.extra-options-body {
    display: grid;
    gap: 14px;
    padding: 0 14px 14px;
}

.connect-checkbox {
    min-height: 39px;
    align-items: center;
    align-self: end;
    padding: 0 4px;
}

.connect-submit {
    width: 100%;
    min-height: 44px;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    font-weight: 900;
    font-size: 12px;
}

.connect-info-card h2 {
    margin: 16px 0 10px;
    font-size: 24px;
}

.connect-info-card p {
    margin: 0;
    color: var(--muted);
}

.info-list {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.info-list div {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-soft) 70%, var(--surface));
}

.info-list strong {
    color: var(--text);
}

.info-list span {
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 1100px) {
    .actions-col {
        width: 235px;
    }
}

@media (max-width: 900px) {
    .connect-shell {
        grid-template-columns: 1fr;
    }

    .connect-info-card {
        order: -1;
    }
}

@media (max-width: 720px) {
    .bulk-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .bulk-actions {
        justify-content: flex-start;
    }

    .form-grid.two-cols,
    .endpoint-grid {
        grid-template-columns: 1fr;
    }

    .connect-card-modern,
    .connect-info-card {
        padding: 20px;
        border-radius: 18px;
    }

    .guest-page {
        padding: 18px;
    }
}

@media (max-width: 640px) {
    .actions-col {
        width: 170px;
    }

    .row-action.text-action {
        min-width: 30px;
        padding: 0 5px;
        font-size: 11px;
    }
}

.app-page.is-loading {
    opacity: 0.78;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.drop-zone-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.upload-file-list li.upload-file-total {
    color: var(--text);
    font-weight: 800;
    background: var(--surface-soft);
}

.icon-button.tiny {
    width: 27px;
    height: 27px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1;
}

.upload-dock {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    width: min(430px, calc(100vw - 40px));
    max-height: min(520px, calc(100vh - 92px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.upload-dock-header {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.upload-dock-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.upload-dock-title strong {
    white-space: nowrap;
}

.upload-dock-title small {
    color: var(--muted);
    font-size: 12px;
}

.upload-dock-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.upload-dock-list {
    min-height: 0;
    max-height: 430px;
    overflow: auto;
    display: grid;
    gap: 8px;
    padding: 10px;
}

.upload-task {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.upload-task.complete {
    border-color: color-mix(in srgb, var(--success) 24%, var(--border));
}

.upload-task.error {
    border-color: color-mix(in srgb, var(--danger) 26%, var(--border));
}

.upload-task.canceled {
    opacity: 0.72;
}

.upload-task-main {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.upload-task-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
    color: var(--text);
}

.upload-task-meta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 12px;
}

.upload-progress {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-soft);
}

.upload-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 0.18s ease;
}

.upload-task.complete .upload-progress span {
    background: var(--success);
}

.upload-task.error .upload-progress span {
    background: var(--danger);
}

.upload-task-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 640px) {
    .upload-dock {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
    }

    .upload-dock-title small {
        display: none;
    }
}

/* Professional bucket tools, previews and object controls */
.object-name-button {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.object-name-button:hover strong {
    color: var(--primary);
}

.row-menu-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.mini-inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 0;
}

.settings-inline-fieldset {
    margin: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
}

.settings-inline-fieldset legend {
    padding: 0 6px;
    color: var(--text-soft);
    font-weight: 900;
}

.upload-extra-options textarea {
    min-height: 88px;
    resize: vertical;
}

.wide-modal {
    width: min(1120px, 100%);
}

.preview-modal {
    width: min(1080px, 100%);
}

.modal-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
}

.settings-card {
    min-width: 0;
    display: grid;
    gap: 12px;
    align-content: start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-soft) 58%, var(--surface));
}

.settings-card.wide-card {
    grid-column: 1 / -1;
}

.settings-card h3 {
    margin: 0;
    font-size: 15px;
}

.textarea-mono {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    line-height: 1.45;
}

.compact-table-wrap {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.versions-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

.versions-table th,
.versions-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.versions-table th {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.versions-table tr:last-child td {
    border-bottom: 0;
}

.version-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill.mini {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.preview-modal-body {
    display: grid;
    gap: 14px;
    padding: 18px;
    min-height: 220px;
}

.preview-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.preview-meta strong,
.preview-meta span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-meta span {
    color: var(--muted);
    font-size: 12px;
}

.preview-image {
    display: block;
    max-width: 100%;
    max-height: min(68vh, 720px);
    object-fit: contain;
    justify-self: center;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.preview-frame {
    width: 100%;
    min-height: min(68vh, 720px);
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.preview-media {
    width: 100%;
    max-height: min(68vh, 620px);
    border-radius: 14px;
    background: #000;
}

.preview-text {
    max-height: min(64vh, 680px);
    overflow: auto;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.preview-empty {
    display: grid;
    gap: 10px;
    place-items: start;
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    color: var(--text-soft);
    background: var(--surface-soft);
}

.preview-empty h3,
.preview-empty p {
    margin: 0;
}

.preview-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.preview-loading {
    color: var(--muted);
}

.connect-info-card {
    position: relative;
    overflow: hidden;
}

.connect-info-card::after {
    content: "";
    position: absolute;
    right: -90px;
    bottom: -90px;
    width: 210px;
    height: 210px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    pointer-events: none;
}

@media (max-width: 980px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .preview-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    .versions-table {
        min-width: 560px;
    }
}

.form-grid.three-cols {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.compact-fieldset {
    padding: 12px;
    margin-top: 6px;
}

.tiny-checkbox {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.lock-status-grid {
    display: grid;
    gap: 10px;
}

.json-details {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

.json-details summary {
    cursor: pointer;
    padding: 10px 12px;
    font-weight: 800;
    color: var(--text-soft);
}

.json-details pre {
    margin: 0;
    padding: 12px;
    max-height: 280px;
    overflow: auto;
    border-top: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.5;
    background: var(--surface-soft);
}

@media (max-width: 760px) {
    .form-grid.three-cols {
        grid-template-columns: 1fr;
    }
}

.modal-footer-inline {
    padding: 0 1.25rem 1rem;
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

/* Action-bar visibility fix: keep object actions inside the viewport on every width. */
.workspace,
.objects-panel,
.table-wrap {
    min-width: 0;
}

.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.objects-table {
    min-width: 0;
    width: 100%;
}

.objects-table th.actions-col,
.objects-table td.actions-col {
    width: clamp(300px, 23vw, 390px);
    min-width: 300px;
    max-width: 390px;
    position: sticky;
    right: 0;
    z-index: 12;
    text-align: right;
    background: var(--surface);
    box-shadow: -10px 0 18px color-mix(in srgb, var(--bg) 78%, transparent);
}

.objects-table th.actions-col {
    z-index: 22;
}

.object-row:hover td.actions-col {
    background: var(--surface-hover);
}

.row-actions-inline {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}

.row-actions-inline .row-action {
    margin-left: 0;
    flex: 0 0 auto;
}

.row-actions-inline .row-action.text-action {
    min-width: 0;
    height: 30px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1;
}

.row-actions-inline .row-action.text-action:hover {
    border-color: var(--border);
}

.row-more {
    flex: 0 0 auto;
}

.row-menu {
    right: 0;
    max-width: min(360px, calc(100vw - 32px));
}

@media (max-width: 1380px) {
    .objects-table th.actions-col,
    .objects-table td.actions-col {
        width: 230px;
        min-width: 230px;
        max-width: 230px;
    }

    .row-actions-inline .row-action.text-action {
        width: 34px;
        padding: 0;
        overflow: hidden;
        font-size: 0;
    }

    .row-actions-inline .row-action.text-action::before {
        content: attr(data-short);
        font-size: 11px;
        font-weight: 900;
    }
}

@media (max-width: 980px) {
    .objects-table th.actions-col,
    .objects-table td.actions-col {
        width: 184px;
        min-width: 184px;
        max-width: 184px;
    }

    .row-actions-inline {
        gap: 4px;
    }

    .row-actions-inline .row-action.text-action {
        width: 30px;
        height: 29px;
    }
}

@media (max-width: 640px) {
    .objects-table th.actions-col,
    .objects-table td.actions-col {
        width: 156px;
        min-width: 156px;
        max-width: 156px;
    }

    .row-actions-inline .row-action.text-action {
        width: 27px;
        height: 27px;
    }
}

/* Row action menu visibility fix: render the "Altro" menu as a viewport popover.
   This avoids clipping by the scrollable file table and by the sticky Actions column. */
.row-menu.row-menu-floating {
    position: fixed;
    right: auto;
    bottom: auto;
    z-index: 5000;
    width: min(360px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.row-more[open] > summary.row-action {
    border-color: var(--border);
    background: var(--surface-soft);
    color: var(--primary);
}

@media (max-width: 760px) {
    .row-menu.row-menu-floating {
        left: 12px !important;
        right: 12px !important;
        width: auto;
        max-width: none;
    }
}
