/* ROBIN-aligned admin theme.
   Tokens taken from platform.robin-cloud.ru (Ant Design 4 + Rubik):
     --antd-wave-shadow-color: #373D48
     body color: rgba(38,38,38,.85), background #fff
     font: Rubik 12px / 1.5715, font-feature-settings: "tnum"
     scrollbar thumb #afb8c6 with 4px white border
   Red (#E63946 / #C72329 / #EF3747) is the ROBIN logo color, not the UI brand. */
:root {
    color-scheme: light;
    --robin-primary: #373d48;
    --robin-primary-hover: #2c3139;
    --robin-primary-soft: rgba(55, 61, 72, 0.08);
    --robin-primary-soft-hover: rgba(55, 61, 72, 0.14);

    --robin-red: #ee2340;
    --robin-red-dark: #c72329;
    --robin-red-light: #ef3747;

    --bg-body: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-hover: #fafafa;

    --ink: rgba(38, 38, 38, 0.85);
    --ink-strong: #262626;
    --ink-secondary: rgba(38, 38, 38, 0.65);
    --muted: rgba(38, 38, 38, 0.45);
    --muted-soft: rgba(38, 38, 38, 0.25);

    --line: #d9d9d9;
    --line-soft: #f0f0f0;
    --line-soft-2: #e8e8e8;

    --danger: #ff4d4f;
    --success: #52c41a;
    --warning: #faad14;
    --info: #1890ff;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 9px 28px 8px rgba(0, 0, 0, 0.05), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12);
    --shadow-focus: 0 0 0 2px rgba(55, 61, 72, 0.18);

    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --sidebar-width: 232px;
    --header-height: 60px;

    --btn-on-primary: #ffffff;
    --lamp-halo: #ffffff;
    --login-field-bg: #ffffff;
    --login-field-border: #d3d9e2;
    --login-submit-bg: #ffffff;
    --login-submit-fg: #262626;
    --login-submit-border: #262626;
    --login-submit-hover-bg: #262626;
    --login-submit-hover-fg: #ffffff;
    --theme-switch-track: #e8ecf2;
    --theme-switch-thumb: #d4dbe8;
    --theme-switch-icon-muted: rgba(38, 38, 38, 0.38);
    --theme-switch-icon-active: #262626;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --robin-primary: #a8b0c0;
    --robin-primary-hover: #c5ccd8;
    --robin-primary-soft: rgba(168, 176, 192, 0.14);
    --robin-primary-soft-hover: rgba(168, 176, 192, 0.22);

    --bg-body: #0f1114;
    --bg-surface: #1a1d22;
    --bg-hover: #242830;

    --ink: rgba(240, 240, 240, 0.88);
    --ink-strong: #f0f0f0;
    --ink-secondary: rgba(230, 230, 230, 0.72);
    --muted: rgba(200, 200, 200, 0.55);
    --muted-soft: rgba(180, 180, 180, 0.38);

    --line: #3a404c;
    --line-soft: #252830;
    --line-soft-2: #2e333d;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
    --shadow-focus: 0 0 0 2px rgba(168, 176, 192, 0.35);

    --btn-on-primary: #0f1114;
    --lamp-halo: #1a1d22;
    --login-field-bg: #242830;
    --login-field-border: #3a404c;
    --login-submit-bg: #2c313c;
    --login-submit-fg: #f0f0f0;
    --login-submit-border: #5a6270;
    --login-submit-hover-bg: #f0f0f0;
    --login-submit-hover-fg: #1a1d22;
    --theme-switch-track: #2a2e36;
    --theme-switch-thumb: #3d4450;
    --theme-switch-icon-muted: rgba(240, 240, 240, 0.35);
    --theme-switch-icon-active: #f5f5f5;
}

html[data-theme="dark"] body {
    background-color: var(--bg-body);
    color: var(--ink);
}

* {
    box-sizing: border-box;
}

*::-webkit-scrollbar {
    background-color: var(--bg-surface);
    width: 16px;
    height: 16px;
}

*::-webkit-scrollbar-track {
    background-color: var(--bg-surface);
}

*::-webkit-scrollbar-thumb {
    background-color: #afb8c6;
    border-radius: 16px;
    border: 4px solid var(--bg-surface);
}

*::-webkit-scrollbar-button {
    display: none;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

html {
    font-family: sans-serif;
    line-height: 1.15;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(38, 38, 38, 0);
}

body {
    color: var(--ink);
    background-color: var(--bg-body);
    font-family: Rubik, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 12px;
    line-height: 1.5715;
    font-weight: 400;
    font-variant: tabular-nums;
    font-feature-settings: "tnum";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    vertical-align: middle;
    border-style: none;
}

a {
    color: var(--robin-primary);
    text-decoration: none;
    background-color: transparent;
    outline: none;
    cursor: pointer;
    transition: color 0.3s;
}

a:hover {
    color: var(--robin-primary-hover);
}

/* ──────────────────────────────────────────────────────────────
   Shell: sidebar + header + content
   ────────────────────────────────────────────────────────────── */

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--header-height) minmax(0, 1fr);
    grid-template-areas:
        "sidebar header"
        "sidebar content";
    min-height: 100vh;
    background: var(--bg-body);
}

.sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 14px;
    background: var(--bg-surface);
    border-right: 1px solid var(--line-soft);
    color: var(--ink-strong);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 14px;
}

.brand.compact {
    border-bottom: 0;
    padding: 0 0 12px;
    margin-bottom: 14px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: transparent;
}

.brand-mark img {
    width: 32px;
    height: 32px;
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.brand-wordmark {
    display: block;
    height: 14px;
    width: auto;
}

.brand h1 {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-strong);
    letter-spacing: 0.01em;
}

.brand p {
    margin: 0;
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0;
}

.nav {
    display: grid;
    gap: 2px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--ink-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav a:hover {
    background: var(--bg-hover);
    color: var(--ink-strong);
}

.nav a.active {
    background: var(--robin-primary-soft);
    color: var(--robin-primary);
    font-weight: 500;
}

.nav a .nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: currentColor;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
}

/* ──────────────────────────────────────────────────────────────
   Top header bar
   ────────────────────────────────────────────────────────────── */

.topbar {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--line-soft);
    box-shadow: var(--shadow-xs);
}

.topbar-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.topbar-title h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-strong);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-title .crumb {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-actions .locale-theme-bar {
    flex-wrap: nowrap;
    flex-shrink: 0;
    align-items: center;
}

.topbar-actions .locale-theme-bar .lang-form {
    margin: 0;
}

.topbar-actions .locale-theme-bar .lang-form select {
    width: auto;
    min-width: 128px;
    padding: 4px 11px;
    height: 32px;
    font-size: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    color: var(--ink);
    box-shadow: none;
}

.locale-theme-bar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-form {
    margin: 0;
}

.theme-switch {
    --theme-switch-pad: 3px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 72px;
    height: 32px;
    padding: var(--theme-switch-pad);
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--theme-switch-track);
    position: relative;
    border: 1px solid var(--line-soft-2);
}

.theme-switch::before {
    content: "";
    position: absolute;
    top: var(--theme-switch-pad);
    bottom: var(--theme-switch-pad);
    width: calc(50% - var(--theme-switch-pad) * 1.5);
    border-radius: 999px;
    background: var(--theme-switch-thumb);
    transition: left 0.22s ease, right 0.22s ease;
    z-index: 0;
    pointer-events: none;
}

.theme-switch[data-theme="light"]::before {
    left: var(--theme-switch-pad);
    right: auto;
}

.theme-switch[data-theme="dark"]::before {
    left: auto;
    right: var(--theme-switch-pad);
}

.theme-switch .theme-switch__btn {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    color: var(--theme-switch-icon-muted);
    transition: color 0.18s ease;
    box-shadow: none;
    min-height: 0;
    appearance: none;
}

.theme-switch .theme-switch__btn:hover {
    color: var(--theme-switch-icon-active);
    background: transparent;
    border-color: transparent;
}

.theme-switch .theme-switch__btn:focus-visible {
    box-shadow: 0 0 0 2px var(--robin-primary-soft-hover);
    outline: none;
}

.theme-switch__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.theme-switch[data-theme="light"] .theme-switch__btn:first-of-type,
.theme-switch[data-theme="dark"] .theme-switch__btn:last-of-type {
    color: var(--theme-switch-icon-active);
}

.login-column .locale-theme-bar {
    align-self: flex-start;
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    margin: 0 0 4px;
}

.login-column .locale-theme-bar .lang-form select {
    min-width: 140px;
    height: 40px;
    font-size: 14px;
}

html[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23a8a8a8' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/></svg>");
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background-color: #5a6270;
}

html[data-theme="dark"] .robin-pending {
    border-color: #2a4a6e;
    background: #1a2838;
}

html[data-theme="dark"] .robin-pending h4 {
    color: #8cc8ff;
}

html[data-theme="dark"] .flash {
    border-color: #3d5c3d;
    background: #1a261a;
    color: var(--ink-strong);
}

html[data-theme="dark"] .flash.error {
    border-color: #5c3a3a;
    background: #2a1818;
    color: #ff9c9c;
}

html[data-theme="dark"] .login-page {
    background: linear-gradient(180deg, #141820 0%, #101218 48%, #0c0e12 100%);
}

html[data-theme="dark"] .login-card label {
    color: var(--ink);
}

html[data-theme="dark"] .login-card input[type="text"],
html[data-theme="dark"] .login-card input[type="password"],
html[data-theme="dark"] .login-card input {
    background-color: var(--login-field-bg);
    border-color: var(--login-field-border);
    color: var(--ink-strong);
}

html[data-theme="dark"] .login-card input:hover,
html[data-theme="dark"] .login-card input:focus {
    border-color: var(--robin-primary);
}

html[data-theme="dark"] .login-card select {
    background-color: var(--login-field-bg);
    border-color: var(--login-field-border);
    color: var(--ink-strong);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--ink-strong);
    font-size: 12px;
    font-weight: 500;
}

.topbar-user .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--robin-primary);
    color: var(--btn-on-primary);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

/* ──────────────────────────────────────────────────────────────
   Content
   ────────────────────────────────────────────────────────────── */

.content {
    grid-area: content;
    width: 100%;
    max-width: 1280px;
    padding: 24px;
}

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

.page-head h2,
.topbar-title h2 {
    font-family: "Montserrat", "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page-head h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
    color: var(--ink-strong);
    letter-spacing: -0.005em;
    line-height: 1.3;
}

.page-head p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.muted,
small {
    color: var(--muted);
    font-weight: 400;
}

small {
    display: block;
    font-size: 11.5px;
    line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────
   Grids and panels
   ────────────────────────────────────────────────────────────── */

.grid,
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.docs-grid {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
    min-width: 0;
    margin-bottom: 16px;
}

.health-grid .tile {
    min-width: 0;
}

a.tile.tile-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

a.tile.tile-link:hover {
    border-color: var(--robin-primary);
    box-shadow: var(--shadow-focus);
}

.tile .status-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.panel,
.tile {
    background: var(--bg-surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: 20px 24px;
    margin-bottom: 16px;
    overflow: visible;
    position: relative;
    z-index: 0;
}

.panel:focus-within,
.panel:hover {
    z-index: 1;
}

.tile {
    padding: 14px 16px;
}

.tile span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tile strong {
    display: block;
    margin-top: 6px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ink-strong);
}

h3 {
    margin: 0 0 14px;
    font-family: "Montserrat", "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-strong);
    letter-spacing: 0;
}

/* ──────────────────────────────────────────────────────────────
   Forms
   ────────────────────────────────────────────────────────────── */

form {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 4px;
    color: var(--ink-strong);
    font-weight: 400;
    font-size: 12px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-strong);
}

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

input,
textarea,
select {
    width: 100%;
    height: 32px;
    padding: 4px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--ink);
    font-size: 12px;
    line-height: 1.5715;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

textarea {
    height: auto;
    min-height: 76px;
    padding: 6px 11px;
    resize: vertical;
    font-family: inherit;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-soft);
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--robin-primary);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--robin-primary);
    outline: 0;
    box-shadow: var(--shadow-focus);
}

input[type="checkbox"] {
    width: 14px;
    height: 14px;
    padding: 0;
    accent-color: var(--robin-primary);
}

label.checkbox-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

label.checkbox-row input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

label.checkbox-row > span {
    flex: 1 1 auto;
    min-width: 0;
}

label.checkbox-row small {
    flex: 0 0 100%;
    margin-left: 24px;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23999' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 30px;
}

/* ──────────────────────────────────────────────────────────────
   Buttons
   ────────────────────────────────────────────────────────────── */

button {
    appearance: none;
    border: 1px solid var(--robin-primary);
    border-radius: var(--radius-sm);
    padding: 4px 16px;
    height: 32px;
    background: var(--robin-primary);
    color: var(--btn-on-primary);
    cursor: pointer;
    font-weight: 400;
    font-size: 12px;
    line-height: 1.5715;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
    user-select: none;
    white-space: nowrap;
}

button:hover {
    background: var(--robin-primary-hover);
    border-color: var(--robin-primary-hover);
}

button:focus-visible {
    outline: 0;
    box-shadow: var(--shadow-focus);
}

button:active {
    transform: translateY(0);
}

button.secondary,
button.ghost {
    background: var(--bg-surface);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
}

button.secondary:hover,
button.ghost:hover {
    background: var(--bg-surface);
    border-color: var(--robin-primary);
    color: var(--robin-primary);
}

button.ghost.full {
    background: transparent;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.full {
    width: 100%;
}

/* ──────────────────────────────────────────────────────────────
   Status indicators
   ────────────────────────────────────────────────────────────── */

.lamp {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    vertical-align: middle;
    box-shadow: 0 0 0 2px var(--lamp-halo);
}

.lamp-ok {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--lamp-halo), 0 0 6px rgba(82, 196, 26, 0.5);
}

.lamp-error {
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--lamp-halo), 0 0 6px rgba(255, 77, 79, 0.5);
}

.lamp-expired {
    background: var(--warning);
    box-shadow: 0 0 0 2px var(--lamp-halo), 0 0 6px rgba(250, 173, 20, 0.5);
}

.lamp-unconfigured {
    background: var(--muted-soft);
}

.lamp-pending {
    background: var(--info);
    box-shadow: 0 0 0 2px var(--lamp-halo), 0 0 6px rgba(24, 144, 255, 0.5);
}

/* ──────────────────────────────────────────────────────────────
   Robin section specifics
   ────────────────────────────────────────────────────────────── */

.robin-pending {
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid #91d5ff;
    border-radius: var(--radius-lg);
    background: #e6f7ff;
}

.robin-pending h4 {
    margin: 0 0 6px;
    font-size: 14px;
    color: #096dd9;
    font-weight: 500;
}

.robin-advanced {
    margin: 8px 0;
}

.robin-advanced > summary,
.robin-import > summary {
    cursor: pointer;
    color: var(--ink-secondary);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    user-select: none;
}

.robin-advanced[open] > summary,
.robin-import[open] > summary {
    color: var(--ink-strong);
}

.panel-head-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.panel-head-row h3 {
    margin: 0;
    flex: 1;
}

.robin-status-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.robin-meta p {
    margin: 4px 0;
    color: var(--muted);
    font-size: 12px;
}

.robin-error {
    color: var(--danger);
}

.panel-robin {
    border-top: 2px solid var(--robin-red);
}

/* ──────────────────────────────────────────────────────────────
   Flash messages
   ────────────────────────────────────────────────────────────── */

.flash {
    margin-bottom: 16px;
    padding: 8px 16px;
    border: 1px solid #b7eb8f;
    border-radius: var(--radius-lg);
    background: #f6ffed;
    color: var(--ink-strong);
    font-size: 12px;
    box-shadow: var(--shadow-xs);
}

.flash.error {
    border-color: #ffccc7;
    background: #fff2f0;
    color: #cf1322;
}

/* ──────────────────────────────────────────────────────────────
   Lists (servers, logs)
   ────────────────────────────────────────────────────────────── */

.server-list,
.log-list {
    display: grid;
    gap: 0;
}

.server-item,
.log-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-top: 1px solid var(--line-soft);
}

.server-item:first-child,
.log-item:first-child {
    border-top: 0;
    padding-top: 0;
}

.server-item p {
    margin: 3px 0 0;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 12px;
}

.log-item strong {
    color: var(--ink-strong);
    font-weight: 500;
}

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

/* ──────────────────────────────────────────────────────────────
   Login page — split-screen (Robin/Keycloak login theme)
   ────────────────────────────────────────────────────────────── */

.login-page {
    margin: 0;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    overflow-x: hidden;
    overflow-y: auto;
    background: linear-gradient(180deg, #f9fafc 0%, #fdfdfd 47.92%, #f0eff4 100%);
    user-select: none;
}

.login-shell {
    flex-grow: 1;
    background-image: url("/static/images/robin-login-bg.svg");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: right center;
    order: 2;
}

/* Outer column: locale bar + form must not be nested forms (invalid HTML). */
.login-column {
    order: 1;
    position: relative;
    z-index: 2;
    overflow: visible;
    background: var(--bg-surface);
    width: 26%;
    min-width: 26%;
    padding: 80px 60px 40px 178px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.login-column form.login-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    flex: 1 1 auto;
    min-height: 0;
}

.login-card .brand {
    border-bottom: 0;
    padding: 0;
    margin: 0 0 30px;
    align-items: center;
    gap: 12px;
}

.login-card .brand-mark img {
    width: 40px;
    height: 40px;
}

.login-card .brand-wordmark {
    height: 16px;
}

.login-card .brand p {
    font-size: 14px;
    color: var(--ink-secondary);
}

.login-card h2,
.login-card .login-title {
    font-family: "Montserrat", "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0 0 6px;
    font-size: 32px;
    font-weight: 600;
    color: var(--ink-strong);
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.login-card label {
    font-size: 14px;
    color: var(--ink);
    padding-bottom: 0;
    gap: 8px;
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card input {
    height: auto;
    background-color: var(--login-field-bg);
    border: 1px solid var(--login-field-border);
    padding: 10px 11px;
    color: var(--ink-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 24px;
    box-shadow: none;
}

.login-card input:hover,
.login-card input:focus {
    border-color: var(--ink-strong);
    box-shadow: none;
    outline: 0;
}

.login-card select {
    width: 100%;
    min-height: 44px;
    padding: 8px 11px;
    border: 1px solid var(--login-field-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 24px;
    background-color: var(--login-field-bg);
    color: var(--ink-strong);
    font-family: inherit;
}

.login-card .submit-pill {
    height: 48px;
    background: var(--login-submit-bg);
    color: var(--login-submit-fg);
    border: 1px solid var(--login-submit-border);
    border-radius: 24px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 400;
    font-size: 14px;
    padding: 10px 20px;
    box-shadow: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin-top: 8px;
}

.login-card .submit-pill:hover {
    background: var(--login-submit-hover-bg);
    color: var(--login-submit-hover-fg);
    border-color: var(--login-submit-hover-bg);
}

.login-card .flash.error {
    color: #fa625c;
    background: transparent;
    border: 0;
    padding: 0 2px;
    margin-bottom: 0;
}

.login-card .login-alt {
    margin: 0;
    text-align: center;
    font-size: 14px;
    color: var(--ink-secondary);
}

.login-card .login-alt a {
    color: var(--robin-primary);
    font-weight: 500;
    text-decoration: none;
}

.login-card .login-alt a:hover {
    text-decoration: underline;
}

.login-card .login-robin-intro {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--ink-secondary);
    line-height: 1.5;
}

.login-card textarea {
    width: 100%;
    min-height: 72px;
    padding: 10px 11px;
    border: 1px solid var(--login-field-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    resize: vertical;
    background-color: var(--login-field-bg);
    color: var(--ink-strong);
}

.login-card .login-back {
    margin: 0;
    font-size: 13px;
}

.login-card .login-back a {
    color: var(--robin-primary);
    text-decoration: none;
}

.login-card .login-back a:hover {
    text-decoration: underline;
}

.login-version {
    margin-top: auto;
    padding-top: 24px;
    text-align: left;
    border-top: 1px solid var(--line-soft);
}

.app-version {
    margin: 0;
    font-size: 11px;
    color: var(--muted-soft);
    text-align: center;
    letter-spacing: 0.04em;
}

/* ──────────────────────────────────────────────────────────────
   Responsive
   ────────────────────────────────────────────────────────────── */

@media (max-width: 1440px) {
    .login-column {
        min-width: 28%;
        padding: 60px 60px 40px 120px;
    }
}

@media (max-width: 980px) {
    .login-shell {
        display: none;
    }

    .login-column {
        width: 100%;
        min-width: 0;
        padding: 60px 32px 32px;
        align-items: center;
        text-align: center;
    }

    .login-card .brand {
        flex-direction: column;
        gap: 8px;
    }

    .login-page {
        background: var(--bg-body);
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 960px) {
    .shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
        grid-template-areas:
            "header"
            "sidebar"
            "content";
    }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        border-right: 0;
        border-bottom: 1px solid var(--line-soft);
        padding: 12px 16px;
    }

    .brand {
        border-bottom: 0;
        padding: 0;
        margin-bottom: 0;
        margin-right: auto;
    }

    .nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav a {
        padding: 6px 10px;
    }

    .sidebar-footer {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
        flex-direction: row;
        display: flex;
        gap: 8px;
    }

    .sidebar-footer .app-version {
        display: none;
    }

    .topbar {
        padding: 0 16px;
    }

    .content {
        padding: 16px;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .health-grid {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .health-grid .tile {
        flex: 1 0 40%;
        min-width: 140px;
    }
}

/* Field help: label row + "i" + dark tooltip (caret toward icon) */
.field-label-row {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    width: 100%;
}

.field-label-row--checkbox {
    align-items: flex-start;
}

.field-label-text {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    color: var(--ink-strong);
}

.field-label-row--checkbox .field-label-text {
    font-weight: 400;
}

.field-checkbox-input {
    flex: 0 0 auto;
    margin-top: 0.2em;
}

.field-help-wrap {
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    vertical-align: middle;
    padding-bottom: 6px;
    margin-bottom: -6px;
}

.field-help-icon {
    width: 1.15rem;
    height: 1.15rem;
    padding: 0;
    border: 1px solid var(--ink-secondary);
    border-radius: 50%;
    background: var(--bg-surface);
    color: var(--ink-strong);
    font-size: 0.62rem;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    cursor: help;
}

.field-help-icon:hover,
.field-help-icon:focus-visible {
    border-color: var(--robin-primary);
    color: var(--robin-primary);
}

.field-help-tooltip {
    display: none;
    position: absolute;
    z-index: 500;
    left: 50%;
    top: calc(100% + 4px);
    transform: translateX(-50%);
    min-width: 220px;
    max-width: min(420px, 92vw);
    padding: 10px 14px;
    background: #1a1a1a;
    color: #f0f0f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 0.82rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.45;
    white-space: pre-wrap;
    text-align: left;
}

.field-help-tooltip::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #1a1a1a;
}

.field-help-wrap:hover,
.field-help-wrap:focus-within {
    z-index: 400;
}

.field-help-wrap:hover .field-help-tooltip,
.field-help-wrap:focus-within .field-help-tooltip {
    display: block;
}

.label-with-help {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 12px;
}

.label-with-help > input,
.label-with-help > textarea,
.label-with-help > select {
    width: 100%;
    max-width: 100%;
}

.label-with-help--checkbox {
    gap: 0;
    margin-bottom: 10px;
}

label.label-with-help.label-with-help--checkbox.checkbox-row {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
}

.admin-log-view {
    max-height: 70vh;
    overflow: auto;
    padding: 12px;
    margin: 0;
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.45;
}

.log-path {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.log-path .field-label-row {
    align-items: center;
}

.log-path code {
    font-size: 0.8rem;
    word-break: break-all;
}

.robin-mcp-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.robin-mcp-row input[type="text"] {
    flex: 1 1 220px;
    min-width: 180px;
}

form.inline-form {
    display: inline;
}

/* Theme switch buttons: must follow global `button` rules so primary styles never leak through. */
form.theme-form .theme-switch button.theme-switch__btn {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
    white-space: normal;
    line-height: 0;
    font-size: 0;
    cursor: pointer;
    color: var(--theme-switch-icon-muted);
    transition: color 0.18s ease, background-color 0.18s ease;
    appearance: none;
}

form.theme-form .theme-switch button.theme-switch__btn:hover,
form.theme-form .theme-switch button.theme-switch__btn:focus-visible,
form.theme-form .theme-switch button.theme-switch__btn:active {
    background: transparent;
    border-color: transparent;
    color: var(--theme-switch-icon-active);
    box-shadow: none;
    transform: none;
}

form.theme-form .theme-switch button.theme-switch__btn:focus-visible {
    box-shadow: 0 0 0 2px var(--robin-primary-soft-hover);
    outline: none;
}

form.theme-form .theme-switch .theme-switch__icon {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
}

form.theme-form .theme-switch[data-theme="light"] button.theme-switch__btn:first-of-type,
form.theme-form .theme-switch[data-theme="dark"] button.theme-switch__btn:last-of-type {
    color: var(--theme-switch-icon-active);
}

.field-help-wrap button.field-help-icon {
    width: 1.15rem;
    height: 1.15rem;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 1px solid var(--ink-secondary);
    border-radius: 50%;
    background: var(--bg-surface);
    color: var(--ink-strong);
    font-size: 0.62rem;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    white-space: normal;
    box-shadow: none;
    cursor: help;
}

.field-help-wrap button.field-help-icon:hover,
.field-help-wrap button.field-help-icon:focus-visible {
    background: var(--bg-surface);
    border-color: var(--robin-primary);
    color: var(--robin-primary);
}

.field-help-wrap button.field-help-icon:active {
    transform: none;
}
