:root {
    --v2-sidebar: 216px;
    --v2-orange: #f58220;
    --v2-orange-dark: #d96f17;
    --v2-navy: #17233a;
    --v2-blue: #2563a7;
    --v2-bg: #f5f7fb;
    --v2-surface: #ffffff;
    --v2-surface-2: #f8fafc;
    --v2-line: #d9e2ee;
    --v2-line-strong: #c7d2e0;
    --v2-text: #1f2937;
    --v2-muted: #64748b;
    --v2-danger: #b42318;
    --v2-success: #067647;
    --v2-focus: rgba(37, 99, 167, 0.18);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--v2-bg);
    color: var(--v2-text);
    font-family: 'Noto Sans', Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

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

.app-sidebar,
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: var(--v2-sidebar);
    padding: 12px;
    background: var(--v2-navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand-block,
.sidebar-header {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 8px 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-title,
.sidebar-header h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
}

.app-nav,
.nav.flex-column {
    display: grid;
    gap: 2px;
}

.nav-item,
.nav-link,
.logout-btn-small {
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, 0.86);
    text-align: left;
    text-decoration: none;
    font-weight: 700;
}

.nav-item i,
.nav-link i,
.logout-btn-small i {
    width: 16px;
    text-align: center;
    font-size: 15px;
}

.nav-item:hover,
.nav-item.active,
.nav-link:hover,
.nav-link.active,
.logout-btn-small:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.nav-item.active,
.nav-link.active {
    box-shadow: inset 3px 0 0 var(--v2-orange);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 4px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 6px 9px;
    color: rgba(255, 255, 255, 0.75);
}

.app-main,
.main-content {
    margin-left: var(--v2-sidebar);
    padding: 18px 22px 28px;
}

.page-header,
.command-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.page-title,
.command-header h1 {
    margin: 0;
    font-size: 23px;
    line-height: 1.2;
    font-weight: 800;
}

.page-kicker,
.page-subtitle,
.status-line,
.muted {
    color: var(--v2-muted);
}

.page-kicker,
.page-subtitle {
    margin: 3px 0 0;
}

.toolbar,
.command-actions,
.filter-controls,
.card-command-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.command-btn,
.btn-icon,
.row-action,
.mini-action {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--v2-line-strong);
    border-radius: 4px;
    background: #fff;
    color: var(--v2-text);
    padding: 6px 10px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.command-btn i,
.btn-icon i,
.row-action i {
    width: 14px;
    text-align: center;
}

.command-btn:hover,
.btn-icon:hover,
.row-action:hover,
.mini-action:hover {
    border-color: var(--v2-blue);
    color: var(--v2-blue);
    background: #f8fbff;
}

.command-btn.primary,
.btn-primary-ocs {
    background: var(--v2-blue);
    border-color: var(--v2-blue);
    color: #fff;
}

.command-btn.primary:hover,
.btn-primary-ocs:hover {
    background: #1d4f86;
    color: #fff;
}

.row-action.danger,
.btn-danger-ocs {
    color: var(--v2-danger);
    border-color: #fecdca;
}

.form-control,
.form-select,
input,
select,
textarea {
    border-radius: 4px !important;
}

.form-control,
.form-select {
    border-color: var(--v2-line-strong);
}

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--v2-blue) !important;
    box-shadow: 0 0 0 3px var(--v2-focus) !important;
    outline: none;
}

.v2-panel,
.filter-panel,
.resource-filterbar,
.results-shell,
.azure-resource-list,
.panel,
.empty-state,
.resource-state {
    background: var(--v2-surface);
    border: 1px solid var(--v2-line);
    border-radius: 4px;
}

.v2-table,
.results-table,
.resource-table,
.result-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.v2-table th,
.results-table th,
.resource-table th,
.result-table th {
    height: 36px;
    padding: 0 10px;
    border-bottom: 1px solid var(--v2-line);
    background: #fbfcfe;
    color: var(--v2-muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
}

.v2-table td,
.results-table td,
.resource-table td,
.result-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--v2-line);
    vertical-align: middle;
}

.v2-table tbody tr:hover,
.results-table tbody tr:hover,
.resource-table tbody tr:hover {
    background: #f8fbff;
}

.status-pill,
.table-pill {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-pill.ok {
    background: #ecfdf3;
    color: var(--v2-success);
}

.status-pill.muted {
    color: var(--v2-muted);
}

.modal-content,
.app-modal {
    border: 1px solid var(--v2-line);
    border-radius: 4px !important;
}

.toast-stack {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1100;
    display: grid;
    gap: 8px;
}

.app-toast,
.toast-ocs {
    width: min(340px, calc(100vw - 24px));
    padding: 10px 12px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid var(--v2-line);
    border-left: 4px solid var(--v2-success);
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
}

.app-toast.error,
.toast-ocs.error {
    border-left-color: var(--v2-danger);
}

[hidden] {
    display: none !important;
}

@media (max-width: 920px) {
    .app-sidebar,
    .sidebar {
        position: static;
        width: 100%;
    }

    .app-main,
    .main-content {
        margin-left: 0;
        padding: 14px;
    }
}

/* V2 operational shell overrides */
:root {
    --sidebar-width: var(--v2-sidebar);
    --brand: var(--v2-orange);
    --brand-hover: var(--v2-orange-dark);
    --blue: var(--v2-blue);
    --ink: var(--v2-text);
    --muted: var(--v2-muted);
    --line: var(--v2-line);
    --line-strong: var(--v2-line-strong);
    --paper: var(--v2-bg);
    --panel: var(--v2-surface);
    --danger: var(--v2-danger);
    --success: var(--v2-success);
    --focus: var(--v2-focus);
}

.app-sidebar,
.sidebar {
    width: var(--v2-sidebar);
    background: var(--v2-navy) !important;
}

.app-main,
.main-content {
    margin-left: var(--v2-sidebar);
    max-width: none;
}

.brand-block,
.sidebar-header {
    height: 44px;
}

.nav-item,
.nav-link,
.logout-btn-small,
.command-btn,
.btn-icon,
.row-action,
.mini-action,
.segment,
.tab-btn {
    transition: none !important;
}

.command-btn,
.btn-icon,
.row-action {
    min-width: 34px;
}

.command-btn:disabled,
.btn-icon:disabled,
.row-action:disabled {
    opacity: 0.48;
    pointer-events: none;
}

.row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    min-width: 160px;
}

.row-action {
    width: 100%;
    min-width: 78px;
    min-height: 32px;
}

.actions-col {
    width: 176px !important;
}

.row-actions .restore-btn,
.row-actions > .muted {
    grid-column: 1 / -1;
}

.row-action.danger:hover,
.btn-danger-ocs:hover {
    color: var(--v2-danger);
    border-color: var(--v2-danger);
    background: #fff8f7;
}

.filter-panel,
.resource-filterbar,
.azure-resource-list,
.results-shell,
.panel,
.empty-state,
.resource-state,
.status-panel,
.status-inline {
    box-shadow: none !important;
}

.filter-panel,
.resource-filterbar {
    min-height: 56px;
}

.search-control input,
.resource-search input,
.form-control,
.form-select {
    min-height: 36px;
}

.stats-row {
    border-bottom: 1px solid var(--v2-line);
}

.results-table td,
.resource-table td {
    height: 52px;
}

.results-table tr:last-child td,
.resource-table tr:last-child td {
    border-bottom: 0;
}

.cell-title,
.resource-name,
.field-value,
.notes-cell {
    min-width: 0;
}

.password-cell {
    width: 100%;
    justify-content: space-between;
}

.mini-action {
    min-width: 52px;
}

.database-workspace {
    display: grid;
    grid-template-columns: minmax(520px, 1.08fr) minmax(390px, 0.92fr);
    gap: 12px;
    align-items: start;
}

.azure-resource-list,
.schema-panel {
    min-width: 0;
}

.schema-panel.active {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--v2-line) !important;
    border-radius: 4px !important;
    background: var(--v2-surface) !important;
    overflow: hidden !important;
}

.schema-blade-header {
    min-height: 58px !important;
    padding: 10px 12px !important;
    background: #fff !important;
    border-bottom: 1px solid var(--v2-line) !important;
}

.schema-blade-header h2 {
    font-size: 18px !important;
}

.schema-blade-header p:not(.blade-kicker) {
    margin: 2px 0 0 !important;
    font-size: 13px;
}

.schema-blade-body {
    padding: 12px !important;
}

.schema-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
}

.schema-summary div {
    padding: 8px 10px !important;
    box-shadow: none !important;
}

.schema-grid-head,
.schema-row {
    grid-template-columns: minmax(140px, 1fr) 126px 96px minmax(142px, 0.9fr) !important;
    gap: 8px !important;
}

.schema-grid-head {
    height: 34px !important;
}

.schema-row {
    padding: 8px 10px !important;
}

.inline-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.inline-actions .btn-icon {
    width: 100%;
    min-height: 32px;
}

.inline-panel {
    display: none !important;
    grid-template-columns: minmax(160px, 1fr) auto auto;
    align-items: center;
}

.inline-panel.active {
    display: grid !important;
}

.guided-add-column {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin-top: 12px !important;
    padding: 12px !important;
}

.guided-add-column .form-grid {
    grid-template-columns: minmax(160px, 1fr) 150px 120px auto !important;
}

.resource-list-header span:last-child {
    color: var(--v2-muted);
    font-size: 12px;
}

.login-container {
    border-radius: 4px !important;
    box-shadow: 0 18px 48px rgba(16, 24, 40, 0.16) !important;
    transition: none !important;
}

.login-header h1 {
    color: var(--v2-navy) !important;
    font-size: 24px !important;
}

.login-header p {
    color: var(--v2-muted) !important;
}

.btn-main {
    min-height: 38px !important;
    border-radius: 4px !important;
    background: var(--v2-blue) !important;
    font-weight: 800 !important;
    transition: none !important;
}

.btn-main:hover {
    background: #1d4f86 !important;
    transform: none !important;
}

.auth-card,
.setup-panel,
.confirm-panel,
.qr-wrapper,
.manual-key,
.backup-code {
    border-radius: 4px !important;
    box-shadow: none !important;
}

.screen.active {
    animation: none !important;
}

/* Static loading states that match final table/form geometry. */
.skeleton-row {
    pointer-events: none;
}

.skeleton-line,
.skeleton-pill,
.skeleton-button,
.skeleton-input,
.skeleton-radio {
    display: inline-block;
    background: #e7edf5;
    border: 1px solid #dde5ef;
}

.skeleton-line {
    width: 68%;
    height: 12px;
    border-radius: 2px;
}

.skeleton-line.wide {
    width: 88%;
}

.skeleton-line.short {
    display: block;
    width: 42%;
    height: 10px;
    margin-top: 6px;
}

.skeleton-pill {
    width: 78px;
    height: 22px;
    border-radius: 999px;
}

.skeleton-button {
    width: 100%;
    max-width: 92px;
    height: 32px;
    border-radius: 4px;
}

.skeleton-input {
    width: 100%;
    height: 38px;
    border-radius: 4px;
}

.skeleton-radio {
    width: 14px;
    height: 14px;
    border-radius: 999px;
}

.field-grid .skeleton-input {
    margin-top: 4px;
}

.qr-loading {
    display: grid;
    justify-items: center;
    gap: 10px;
    color: var(--v2-muted);
    font-weight: 700;
}

.qr-skeleton {
    width: 180px;
    height: 180px;
    display: block;
    border: 1px solid #d8e1ec;
    background:
        linear-gradient(90deg, #e7edf5 12px, transparent 12px 24px, #e7edf5 24px 36px, transparent 36px),
        linear-gradient(#e7edf5 12px, transparent 12px 24px, #e7edf5 24px 36px, transparent 36px),
        #f8fafc;
    background-size: 48px 48px;
}

/* Azure Data Studio style schema workbench. */
.schema-panel.active {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1200 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    overflow: hidden !important;
}

.schema-workbench {
    display: grid;
    grid-template-columns: 38px 320px minmax(0, 1fr);
    width: 100%;
    height: 100%;
    background: #fff;
    color: #2f343b;
}

.schema-activitybar {
    height: 100vh;
    display: grid;
    grid-auto-rows: 38px;
    align-content: start;
    justify-items: center;
    padding-top: 6px;
    background: #24272d;
    border-right: 1px solid #17191d;
}

.schema-activitybar a,
.schema-activitybar button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    color: #b8bec7;
    text-decoration: none;
    font-size: 17px;
}

.schema-activitybar a:hover,
.schema-activitybar button:hover,
.schema-activitybar .active {
    color: #fff;
    background: #2f333b;
}

.schema-activitybar .active {
    border-left-color: var(--v2-blue);
}

.schema-activitybar button:last-child {
    margin-top: auto;
}

.schema-explorer {
    min-width: 0;
    height: 100vh;
    overflow: auto;
    background: #f3f3f3;
    border-right: 1px solid #cfcfcf;
    color: #4c4f54;
    font-size: 13px;
}

.schema-explorer-title {
    height: 32px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    color: #3f4247;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.schema-server,
.schema-tree-section,
.schema-tree-table,
.schema-tree-empty {
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 22px;
}

.schema-server {
    font-weight: 700;
}

.server-node {
    width: 12px;
    height: 12px;
    border: 1px solid #6b7280;
    border-radius: 2px;
    background: #fff;
    box-shadow: 8px 8px 0 -4px #22c55e;
}

.schema-tree-section {
    font-weight: 700;
}

.schema-tree-section.indent {
    padding-left: 34px;
}

.schema-tree-section.deeper {
    padding-left: 46px;
}

.schema-tree-section .bi-folder-fill {
    color: #d49a3a;
}

.schema-tree-section .bi-database-fill {
    color: #5b626c;
}

.schema-tree-list {
    display: grid;
}

.schema-tree-table {
    width: 100%;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    color: #4c4f54;
    text-align: left;
    padding-left: 58px;
    font-weight: 700;
}

.schema-tree-table i {
    color: #4d5560;
}

.schema-tree-table span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schema-tree-table:hover,
.schema-tree-table.active {
    background: #dfdfdf;
}

.schema-tree-table.active {
    border-left-color: var(--v2-blue);
    color: #1f2937;
}

.schema-editor {
    min-width: 0;
    height: 100vh;
    display: grid;
    grid-template-rows: 40px minmax(220px, 38vh) minmax(0, 1fr);
    background: #fff;
}

.schema-editor-toolbar {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border-bottom: 1px solid #d8d8d8;
    background: #ffffff;
    color: #4c4f54;
    white-space: nowrap;
}

.schema-toolbar-btn {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: #4c4f54;
    padding: 4px 5px;
    font-weight: 700;
}

/* Edit schema / Close reuse the app-wide .btn-icon (34px), but every other
   control in this 40px toolbar is sized off .schema-toolbar-btn (30px) —
   match that so nothing sits flush against the toolbar edges. */
.schema-editor-toolbar .btn-icon {
    min-height: 30px;
    padding: 5px 10px;
}

.schema-toolbar-btn:hover {
    color: var(--v2-blue);
    background: #f2f6fb;
}

.schema-toolbar-btn:disabled {
    opacity: 0.45;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #d8d8d8;
}

.database-select {
    min-width: 190px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 28px 0 10px;
    border: 1px solid #bfc5cc;
    background: #fff;
    color: #30343a;
    font-weight: 700;
    position: relative;
}

.schema-query {
    margin: 0;
    padding: 12px 18px 18px 54px;
    border: 0;
    border-bottom: 1px solid #d8d8d8;
    border-radius: 0;
    background:
        linear-gradient(90deg, #f7f7f7 0 44px, #d8d8d8 44px 45px, #fff 45px);
    color: #111827;
    font: 15px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: pre;
    overflow: auto;
}

.schema-query .skeleton-line {
    display: block;
    margin-bottom: 12px;
}

.schema-result-shell {
    min-height: 0;
    display: grid;
    grid-template-rows: 42px minmax(0, 1fr) auto;
    overflow: hidden;
    background: #fff;
}

.schema-result-tabs {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 20px;
    border-bottom: 1px solid #d8d8d8;
    color: #6b7280;
}

.schema-result-tabs strong {
    height: 100%;
    display: inline-flex;
    align-items: center;
    color: #2f343b;
    border-bottom: 2px solid var(--v2-blue);
}

.schema-result-grid {
    min-height: 0;
    overflow: auto;
}

.schema-result-grid .schema-grid-head,
.schema-result-grid .schema-row {
    /* Capped, not fr-based: schema metadata (column names, "Ready", two
       action buttons) is short and uniform, so letting these stretch to
       fill a wide workbench just leaves huge dead whitespace. */
    grid-template-columns: minmax(220px, 380px) 180px 130px minmax(260px, 320px) !important;
    border-left: 0;
    border-right: 0;
    border-color: #d8d8d8;
}

.schema-result-grid .schema-grid-head {
    position: sticky;
    top: 0;
    z-index: 1;
    height: 38px !important;
    background: #f4f4f4;
    color: #33373d;
    text-transform: none;
    font-size: 13px;
}

.schema-result-grid .schema-row {
    min-height: 40px;
    padding: 6px 10px !important;
}

.schema-result-grid .inline-actions {
    grid-template-columns: repeat(2, minmax(110px, 138px));
}

.schema-result-grid .inline-panel {
    margin-top: 4px;
    background: #f7f7f7;
    border-color: #d8d8d8;
}

.schema-result-shell .guided-add-column {
    margin: 0 !important;
    border: 0;
    border-top: 1px solid #d8d8d8;
    border-radius: 0;
    background: #fafafa;
}

.schema-result-shell .guided-add-column h3 {
    font-size: 14px;
}

.run-dot {
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 11px solid #22a447;
}

@media (max-width: 1180px) {
    .database-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 920px) {
    .app-main,
    .main-content {
        margin-left: 0;
    }

    .schema-grid-head,
    .schema-row,
    .guided-add-column .form-grid,
    .inline-panel {
        grid-template-columns: 1fr !important;
    }

    .schema-workbench {
        grid-template-columns: 1fr;
    }

    .schema-activitybar {
        height: 42px;
        grid-auto-flow: column;
        grid-auto-columns: 42px;
        grid-auto-rows: 42px;
        justify-content: start;
        padding-top: 0;
        border-right: 0;
        border-bottom: 1px solid #17191d;
    }

    .schema-activitybar a,
    .schema-activitybar button {
        width: 42px;
        height: 42px;
        border-left: 0;
        border-bottom: 3px solid transparent;
    }

    .schema-activitybar .active {
        border-bottom-color: var(--v2-blue);
    }

    .schema-explorer {
        height: 34vh;
        border-right: 0;
        border-bottom: 1px solid #cfcfcf;
    }

    .schema-editor {
        height: 66vh;
        grid-template-rows: auto 220px minmax(0, 1fr);
    }

    .schema-editor-toolbar {
        flex-wrap: wrap;
        min-height: 40px;
        padding: 6px 10px;
    }

    .schema-query {
        padding-left: 14px;
        background: #fff;
    }
}
