@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-variable.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Geist";
    src: url("../fonts/geist-variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Roboto";
    src: url("../fonts/roboto-variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-stretch: 75% 100%;
    font-display: swap;
}

@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/plus-jakarta-sans-variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
}

@font-face {
    font-family: "Lato";
    src: url("../fonts/lato-regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Lato";
    src: url("../fonts/lato-semibold.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Lato";
    src: url("../fonts/lato-bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Open Sans";
    src: url("../fonts/open-sans-latin-ext.ttf") format("truetype");
    font-style: normal;
    font-weight: 300 800;
    font-stretch: 75% 100%;
    font-display: swap;
}

@font-face {
    font-family: "Merriweather";
    src: url("../fonts/merriweather-variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 300 900;
    font-stretch: 87% 112%;
    font-display: swap;
}

:root {
    --font-ui: "Inter", sans-serif;
    --primary: #5d87ff;
    --primary-fill: #315fcf;
    --primary-fill-hover: #244dad;
    --primary-soft: #ecf2ff;
    --primary-text: #2f5edb;
    --danger: #b4232d;
    --danger-fill: #c52f3a;
    --danger-fill-hover: #a91f2a;
    --danger-soft: #fff0f1;
    --success: #087252;
    --success-soft: #e8f8f2;
    --warning: #f8a629;
    --page: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-hover: #f6f9fc;
    --text: #2a3547;
    --muted: #5a6a85;
    --muted-2: #5f6e86;
    --border: #e5eaef;
    --border-strong: #d6dee8;
    --scrim: rgb(31 41 55 / 0.55);
    --shadow: 0 2px 7px rgb(41 52 71 / 0.08);
    --shadow-dialog: 0 24px 60px rgb(15 23 42 / 0.24);
    --radius: 14px;
    --radius-control: 8px;
    --sidebar-width: 270px;
    --topbar-height: 70px;
    --focus: 0 0 0 3px rgb(93 135 255 / 0.24);
    --duration: 180ms;
}

html[data-font="arial"] {
    --font-ui: Arial, sans-serif;
}

html[data-font="verdana"] {
    --font-ui: Verdana, sans-serif;
}

html[data-font="tahoma"] {
    --font-ui: Tahoma, sans-serif;
}

html[data-font="inter"] {
    --font-ui: "Inter", sans-serif;
}

html[data-font="geist"] {
    --font-ui: "Geist", sans-serif;
}

html[data-font="roboto"] {
    --font-ui: "Roboto", sans-serif;
}

html[data-font="plus-jakarta-sans"] {
    --font-ui: "Plus Jakarta Sans", sans-serif;
}

html[data-font="lato"] {
    --font-ui: "Lato", sans-serif;
}

html[data-font="open-sans"] {
    --font-ui: "Open Sans", sans-serif;
}

html[data-font="merriweather"] {
    --font-ui: "Merriweather", serif;
}

[data-theme="dark"] {
    --primary: #6c92ff;
    --primary-fill: #456bd0;
    --primary-fill-hover: #3458b8;
    --primary-soft: #263452;
    --primary-text: #9ab3ff;
    --danger: #ff737b;
    --danger-fill: #c43b45;
    --danger-fill-hover: #a92832;
    --danger-soft: #4b2930;
    --success: #38d39f;
    --success-soft: #173d35;
    --warning: #fdb54a;
    --page: #171c26;
    --surface: #202632;
    --surface-2: #262d3a;
    --surface-hover: #29313f;
    --text: #f1f4f9;
    --muted: #b2bdd0;
    --muted-2: #97a5ba;
    --border: #374151;
    --border-strong: #4b5565;
    --scrim: rgb(0 0 0 / 0.72);
    --shadow: 0 2px 8px rgb(0 0 0 / 0.25);
    --shadow-dialog: 0 24px 70px rgb(0 0 0 / 0.55);
    --focus: 0 0 0 3px rgb(108 146 255 / 0.34);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
    color-scheme: light;
    scroll-behavior: smooth;
}

button,
a {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgb(93 135 255 / 0.14);
}

html[data-theme="dark"] {
    color-scheme: dark;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--primary-fill);
    color: #fff;
}

a {
    color: inherit;
    text-decoration: none;
    text-underline-offset: 3px;
}

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

button,
a,
input,
select,
textarea {
    transition: border-color var(--duration) ease, background-color var(--duration) ease, color var(--duration) ease, box-shadow var(--duration) ease, opacity var(--duration) ease;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

img {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 1000;
    padding: 10px 14px;
    border-radius: var(--radius-control);
    background: var(--primary-fill);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: var(--sidebar-width);
    min-height: 100vh;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.sidebar-brand {
    display: flex;
    height: var(--topbar-height);
    align-items: center;
    padding: 0 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.025em;
    text-decoration: none;
}

.brand > span:last-child > span {
    color: var(--primary);
}

.sidebar-nav {
    padding: 0 16px;
}

.nav-heading {
    margin: 4px 12px 9px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
}

.nav-link {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 13px;
    margin-bottom: 4px;
    padding: 0 14px;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.nav-button {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
}

.nav-link img,
.logout-button img,
.theme-indicator img {
    width: 20px;
    height: 20px;
    opacity: 0.72;
}

.nav-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav-link.is-active {
    background: var(--primary-fill);
    box-shadow: 0 7px 16px rgb(93 135 255 / 0.22);
    color: #fff;
}

.nav-link.is-active img,
.button-primary img,
.button-danger img {
    filter: brightness(0) invert(1);
    opacity: 1;
}

.main-column {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
}

.topbar-actions,
.theme-indicator,
.topbar-user-context {
    display: flex;
    align-items: center;
}

.topbar-product {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.topbar-product a {
    color: var(--primary-text);
    font-weight: inherit;
    text-decoration: none;
}

.topbar-user-context {
    min-width: 0;
    gap: 9px;
}

.topbar-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
}

.topbar-avatar img {
    width: 18px;
    height: 18px;
}

.topbar-actions {
    gap: 18px;
}

.theme-indicator {
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
}

.theme-indicator img {
    width: 17px;
    height: 17px;
}

.topbar-user {
    overflow: hidden;
    color: var(--primary-text);
    font-weight: 400;
    text-overflow: ellipsis;
    text-decoration: none;
    white-space: nowrap;
}

.topbar-user:hover {
    color: var(--primary-fill-hover);
    text-decoration: none;
}

.content {
    width: 100%;
    max-width: 1700px;
    min-height: calc(100vh - 126px);
    margin: 0 auto;
    padding: 28px 30px 40px;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 12px;
}

.breadcrumbs a {
    color: var(--primary-text);
    text-decoration: none;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.page-heading h1 {
    margin: 0;
    font-size: 23px;
    line-height: 1.3;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

h1,
h2,
h3 {
    scroll-margin-top: calc(var(--topbar-height) + 16px);
    text-wrap: balance;
}

.page-heading p {
    margin: 6px 0 0;
    color: var(--muted);
}

.card {
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    padding: 19px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h2,
.table-toolbar h2 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.card-header p,
.table-toolbar p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    cursor: pointer;
    font-weight: 400;
    text-decoration: none;
}

.button img {
    width: 18px;
    height: 18px;
}

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

.button-primary {
    background: var(--primary-fill);
    box-shadow: 0 5px 12px rgb(93 135 255 / 0.2);
    color: #fff;
}

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

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

.button-secondary:hover {
    border-color: var(--primary);
    color: var(--primary-text);
}

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

.button-danger:hover {
    background: var(--danger-fill-hover);
}

.button-full {
    width: 100%;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    padding: 13px 15px;
    border-radius: 9px;
    font-weight: 600;
}

.alert:focus,
.alert:focus-visible {
    outline: none;
}

.alert img {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.table-toolbar {
    display: flex;
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

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

.search-form > img {
    position: absolute;
    top: 50%;
    left: 13px;
    width: 18px;
    height: 18px;
    opacity: 0.58;
    pointer-events: none;
    transform: translateY(-50%);
}

.search-form input {
    width: 100%;
    height: 42px;
    padding: 0 42px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    background: var(--surface);
}

.search-form input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus);
    outline: none;
}

.search-clear {
    position: absolute;
    top: 50%;
    right: 9px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 6px;
    transform: translateY(-50%);
}

.search-clear:hover {
    background: var(--surface-hover);
}

.search-clear img {
    width: 16px;
    height: 16px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    scrollbar-color: var(--border-strong) var(--surface-2);
    scrollbar-width: thin;
}

table {
    width: 100%;
    min-width: 1260px;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

th,
td {
    padding: 15px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th:first-child,
td:first-child {
    padding-left: 24px;
}

th:last-child,
td:last-child {
    padding-right: 24px;
}

th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: none;
    white-space: nowrap;
}

td {
    color: var(--text);
    font-size: 13px;
}

tbody tr:hover {
    background: var(--surface-hover);
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr.is-inactive > td:not(:last-child) {
    color: var(--muted-2);
    opacity: 0.7;
}

.options-column {
    width: 228px;
}

.copy-cell {
    display: inline-flex;
    max-width: 240px;
    align-items: center;
    gap: 7px;
}

.name-cell {
    min-width: 150px;
}

.slug-cell {
    min-width: 150px;
}

.copy-button {
    display: grid;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    opacity: 0.45;
}

.copy-button:hover,
.copy-button:focus-visible {
    background: var(--primary-soft);
    opacity: 1;
}

.copy-button img {
    width: 14px;
    height: 14px;
}

.table-name,
.table-name-static {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-name {
    color: var(--primary-text);
    font-weight: 400;
    text-decoration: none;
}

.table-name-static {
    font-weight: 700;
}

.table-name-button {
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-weight: 400;
    text-align: left;
}

.description-cell {
    max-width: 270px;
    color: var(--muted);
}

.notes-table {
    min-width: 760px;
}

.note-content {
    display: flex;
    min-width: 260px;
    max-width: 620px;
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
}

.note-description {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

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

.muted {
    color: var(--muted-2);
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.row-actions form {
    display: contents;
}

.icon-button {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
}

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

.icon-button-danger:hover,
.icon-button-danger {
    color: var(--danger);
}

.icon-button-danger:hover {
    background: var(--danger-soft);
}

.icon-button img {
    width: 17px;
    height: 17px;
}

.icon-button-danger img {
    filter: invert(37%) sepia(99%) saturate(1808%) hue-rotate(331deg) brightness(103%);
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.28;
}

.empty-state {
    display: flex;
    min-height: 350px;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    padding: 42px 24px;
    text-align: center;
}

.empty-icon {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 50%;
    background: var(--primary-soft);
}

.empty-icon img {
    width: 28px;
    height: 28px;
}

.empty-state h3 {
    margin: 0;
    font-size: 17px;
}

.empty-state p {
    max-width: 460px;
    margin: 7px 0 19px;
    color: var(--muted);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    padding: 17px 24px;
    border-top: 1px solid var(--border);
}

.page-link {
    display: grid;
    min-width: 35px;
    height: 35px;
    place-items: center;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.page-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.page-link.is-current {
    background: var(--primary-fill);
    color: #fff;
}

.page-link.is-disabled {
    pointer-events: none;
    opacity: 0.35;
}

.page-link img {
    width: 17px;
    height: 17px;
}

.horizontal-form {
    padding: 8px 24px 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 220px minmax(0, 680px);
    gap: 28px;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.form-row-top {
    align-items: start;
}

.form-row > label,
.form-label {
    color: var(--text);
    font-weight: 600;
}

.form-row label > span {
    color: var(--danger);
}

.field-control {
    width: 100%;
}

.field-control input,
.field-control select,
.field-control textarea,
.field input,
.field select {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    background: var(--surface);
}

.field-control input,
.field-control select,
.field input,
.field select {
    height: 42px;
    padding: 0 13px;
}

.field-control textarea {
    min-height: 210px;
    padding: 12px 13px;
    line-height: 1.6;
    resize: vertical;
}

.field-control textarea[name^="wartosc_"] {
    min-height: 420px;
}

.field-control input:hover,
.field-control select:hover,
.field-control textarea:hover,
.field input:hover,
.field select:hover {
    border-color: var(--muted-2);
}

.field-control input:focus,
.field-control select:focus,
.field-control textarea:focus,
.field input:focus,
.field select:focus {
    border-color: var(--primary);
    box-shadow: var(--focus);
    outline: none;
}

.field-control input[readonly] {
    background: var(--surface-2);
    color: var(--muted);
}

.field-control small,
.field small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding: 22px 0 0 248px;
}

.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.tabs button {
    position: relative;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 400;
}

.tabs button::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: transparent;
    content: "";
}

.tabs button[aria-selected="true"] {
    color: var(--primary-text);
}

.tabs button[aria-selected="true"]::after {
    background: var(--primary);
}

.tab-panel[hidden] {
    display: none;
}

.settings-card {
    max-width: 960px;
}

.settings-card + .settings-card {
    margin-top: 20px;
}

.settings-connection-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.settings-connection-name {
    overflow: hidden;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-dialog {
    width: min(980px, calc(100% - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow-dialog);
    color: var(--text);
    overflow: hidden;
    overscroll-behavior: contain;
}

.record-dialog::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(2px);
}

.record-dialog-panel {
    position: relative;
    display: flex;
    max-height: calc(100dvh - 32px);
    flex-direction: column;
}

.record-dialog-header {
    position: relative;
    flex: 0 0 auto;
    padding: 22px 64px 20px 24px;
    border-bottom: 1px solid var(--border);
}

.record-dialog-header h2 {
    margin: 0;
    font-size: 20px;
}

.record-copy-status {
    position: absolute;
    top: 76px;
    right: 16px;
    z-index: 3;
    padding: 9px 12px;
    border-radius: 7px;
    background: var(--text);
    box-shadow: var(--shadow-dialog);
    color: var(--surface);
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
}

.record-copy-status.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.record-dialog-scroll {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

.record-details-table {
    width: 100%;
    min-width: 640px;
    table-layout: fixed;
    border-collapse: collapse;
}

.record-details-table th:first-child,
.record-details-table td:first-child {
    width: 30%;
}

.record-details-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
}

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

.record-data-cell {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 12px;
}

.record-field-name {
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.record-field-value {
    display: block;
    min-width: 0;
    margin: 0;
    color: var(--text);
    font: inherit;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    word-break: break-word;
}

.record-field-value:empty::before {
    color: var(--muted-2);
    content: "-";
}

.confirm-dialog {
    width: min(460px, calc(100% - 32px));
    padding: 0;
    border: 0;
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow-dialog);
    color: var(--text);
    overscroll-behavior: contain;
}

.confirm-dialog::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(2px);
}

.confirm-dialog form {
    position: relative;
    padding: 29px;
    text-align: center;
}

.dialog-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
}

.dialog-close:hover {
    background: var(--surface-hover);
}

.dialog-close img {
    width: 18px;
    height: 18px;
}

.dialog-icon {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--danger-soft);
}

.dialog-icon img {
    width: 25px;
    height: 25px;
    filter: invert(37%) sepia(99%) saturate(1808%) hue-rotate(331deg) brightness(103%);
}

.dialog-icon-lock {
    background: var(--primary-soft);
}

.dialog-icon-lock img,
[data-theme="dark"] .dialog-icon-lock img {
    filter: none;
}

.confirm-dialog h2 {
    margin: 0;
    font-size: 20px;
}

.confirm-dialog p {
    margin: 9px auto 23px;
    color: var(--muted);
}

.dialog-actions {
    display: flex;
    justify-content: center;
    gap: 9px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 100;
    padding: 11px 15px;
    border-radius: 8px;
    background: var(--text);
    box-shadow: var(--shadow-dialog);
    color: var(--surface);
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px 22px;
    color: var(--muted-2);
    font-size: 11px;
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 18px;
    background:
        radial-gradient(circle at 15% 10%, rgb(93 135 255 / 0.12), transparent 32%),
        var(--page);
}

.auth-shell {
    width: min(450px, 100%);
}

.auth-card {
    padding: 34px;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 36px rgb(42 53 71 / 0.12);
}

.auth-brand {
    margin-bottom: 30px;
}

.auth-step {
    margin: 0 0 6px;
    color: var(--primary-text);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.auth-card h1 {
    margin: 0;
    font-size: 23px;
    letter-spacing: -0.025em;
}

.auth-description {
    margin: 8px 0 24px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 17px;
}

.field label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
}

.auth-footnote {
    margin: 16px 0 0;
    color: var(--muted-2);
    font-size: 11px;
    text-align: center;
}

.connection-return {
    margin-top: 14px;
}

.connection-picker {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
}

.connection-picker legend {
    margin-bottom: 8px;
    font-weight: 600;
}

.connection-option {
    position: relative;
    display: flex;
    min-height: 64px;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
}

.connection-option:hover {
    border-color: var(--primary);
}

.connection-option input {
    position: absolute;
    opacity: 0;
}

.connection-option-mark {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
}

.connection-option input:checked + .connection-option-mark {
    border: 5px solid var(--primary);
}

.connection-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.connection-option:has(input:focus-visible) {
    box-shadow: var(--focus);
}

.connection-option strong,
.connection-option small {
    display: block;
}

.connection-option small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

[data-theme="dark"] img:not(.brand-image) {
    filter: invert(0.9);
}

[data-theme="dark"] .nav-link.is-active img,
[data-theme="dark"] .button-primary img,
[data-theme="dark"] .button-danger img {
    filter: brightness(0) invert(1);
}

[data-theme="dark"] .icon-button-danger img,
[data-theme="dark"] .dialog-icon img {
    filter: invert(48%) sepia(88%) saturate(1990%) hue-rotate(323deg) brightness(108%);
}

[data-theme="dark"] .dialog-icon-lock img {
    filter: invert(0.9);
}

button:not(.table-name-button) {
    font-weight: 400;
}

.sidebar-nav .nav-button {
    font-weight: 600;
}

@media (min-width: 821px) {
    .table-scroll > table th,
    .record-details-table th {
        font-size: 13px;
    }

    .table-scroll > table td,
    .record-details-table td {
        font-size: 15px;
    }

    .table-scroll > table .date-cell,
    .table-scroll > table .note-description,
    .record-details-table .record-field-name {
        font-size: 14px;
    }
}

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

    .content,
    .topbar {
        padding-right: 22px;
        padding-left: 22px;
    }

    .sidebar-brand {
        padding: 0 20px;
    }
}

@media (max-width: 820px) {
    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-brand {
        height: 62px;
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        padding-bottom: 14px;
    }

    .nav-heading {
        grid-column: 1 / -1;
    }

    .nav-link {
        margin: 0;
    }

    .main-column {
        margin-left: 0;
    }

    .topbar {
        position: static;
        height: 58px;
    }

    .content {
        min-height: auto;
    }

    .form-row {
        grid-template-columns: 160px minmax(0, 1fr);
        gap: 20px;
    }

    .form-actions {
        padding-left: 180px;
    }
}

@media (max-width: 560px) {
    .content {
        padding: 20px 14px 32px;
    }

    .topbar {
        padding: 0 14px;
    }

    .theme-indicator {
        display: none;
    }

    .sidebar-nav {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading .button {
        width: 100%;
    }

    .table-toolbar {
        padding: 17px;
    }

    .search-form {
        width: 100%;
    }

    .card-header {
        padding: 17px;
    }

    .horizontal-form {
        padding: 7px 17px 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .form-actions {
        padding-left: 0;
    }

    .settings-connection-control {
        align-items: stretch;
        flex-direction: column;
    }

    .record-details-table {
        min-width: 100%;
    }

    .record-details-table th:first-child,
    .record-details-table td:first-child {
        width: 46%;
    }

    .record-details-table th,
    .record-details-table td {
        padding: 10px 11px;
    }

    .record-data-cell {
        gap: 6px;
    }

    .record-field-name,
    .record-field-value {
        min-width: 0;
        font-size: 11px;
    }

    .auth-card {
        padding: 27px 22px;
    }

    .dialog-actions {
        flex-direction: column-reverse;
    }

    .dialog-actions .button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
