:root {
  --font-sans: "Geist", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --canvas: #f4f5f2;
  --surface: #ffffff;
  --surface-subtle: #f8f9f7;
  --surface-strong: #e9ece8;
  --ink: #17201e;
  --ink-soft: #53605d;
  --ink-faint: #65706d;
  --line: #c6cec8;
  --line-strong: #aeb8b1;
  --accent: #14786f;
  --accent-strong: #0c615a;
  --accent-soft: #dcefeb;
  --danger: #b33b3b;
  --danger-soft: #f8e8e6;
  --warning: #8b5c14;
  --warning-soft: #f8efd9;
  --sidebar: #1c2523;
  --sidebar-soft: #283330;
  --shadow: 0 18px 45px rgba(34, 48, 44, 0.08);
  --shadow-high: 0 28px 80px rgba(25, 38, 34, 0.18);
  --radius-sm: 7px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
  font-family: var(--font-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  scroll-behavior: smooth;
}

html.has-modal { overflow: hidden; }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button,
select,
input[type="checkbox"] { cursor: pointer; }

button:disabled,
select:disabled,
input:disabled,
textarea:disabled { cursor: not-allowed; }

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

h1,
h2,
h3,
p,
dl,
dd { margin-top: 0; }

h1,
h2,
h3,
strong { letter-spacing: -0.025em; }

h1 { margin-bottom: 14px; font-size: clamp(2rem, 4vw, 3.6rem); font-weight: 620; line-height: .98; }
h2 { margin-bottom: 10px; font-size: clamp(1.45rem, 2.4vw, 2.15rem); font-weight: 620; line-height: 1.08; }
h3 { margin-bottom: 8px; font-size: 1.08rem; font-weight: 650; }
small { font-size: .78rem; }

[hidden] { display: none !important; }

:focus-visible { outline: 3px solid rgba(20, 120, 111, .28); outline-offset: 2px; }

::selection { background: var(--accent-soft); color: var(--ink); }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  border-radius: var(--radius-sm);
  background: var(--ink);
  padding: 10px 14px;
  color: #fff;
  transition: transform 180ms var(--ease);
}

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

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 720;
  letter-spacing: .12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.eyebrow--light { color: #96d1ca; }

.page-lead { max-width: 68ch; margin-bottom: 0; color: var(--ink-soft); font-size: 1rem; }

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  font-size: 1.02rem;
  font-weight: 760;
  letter-spacing: -.02em;
}

.brand > span:last-child { min-width: 0; }

.brand small { display: block; color: var(--ink-faint); font-size: .7rem; font-weight: 600; letter-spacing: 0; }
.brand--inverted { color: #fff; }
.brand--inverted small { color: #91a09b; }
.brand--compact { gap: 8px; }

.brand__mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  transform: rotate(-3deg);
}

.brand__mark span { border-radius: 2px; background: var(--accent); }
.brand__mark span:first-child { grid-row: 1 / 3; }
.brand__mark span:last-child { background: #82beb7; }
.brand__mark--large { width: 52px; height: 52px; gap: 5px; }

.status-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #7b8783; }
.status-dot.is-online { background: #51b6a8; animation: status-breathe 2.8s var(--ease) infinite; }

.button,
.icon-button {
  border: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 180ms var(--ease), background-color 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease), opacity 180ms var(--ease);
}

.button {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: .9rem;
  font-weight: 650;
  white-space: nowrap;
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active { transform: translateY(1px) scale(.985); }
.button:disabled { opacity: .42; }
.button--primary { background: var(--accent); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--accent-strong); }
.button--secondary { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.button--secondary:hover:not(:disabled) { border-color: #a8b4af; background: var(--surface-subtle); }
.button--quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.button--quiet:hover:not(:disabled) { background: var(--surface-strong); color: var(--ink); }
.button--compact { min-height: 36px; padding: 7px 11px; font-size: .82rem; }
.button--wide { width: 100%; }
.button.is-loading { color: transparent; pointer-events: none; }
.button.is-loading::after { position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.38); border-top-color: #fff; border-radius: 50%; content: ""; animation: spin 800ms linear infinite; }
.button--secondary.is-loading::after,
.button--quiet.is-loading::after { border-color: rgba(20,120,111,.2); border-top-color: var(--accent); }
.button-arrow { font-size: 1.2rem; line-height: 1; }

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.2rem;
}

.icon-button--quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.icon-button--quiet:hover { background: var(--surface-strong); color: var(--ink); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid--tight { gap: 10px; }
.form-grid__wide { grid-column: 1 / -1; }

.field-group { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field-group label { color: var(--ink); font-size: .82rem; font-weight: 650; }
.field-group label small { margin-left: 5px; color: var(--ink-faint); font-weight: 520; }
.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), background-color 180ms var(--ease);
}

.field-group input:hover:not(:disabled),
.field-group select:hover:not(:disabled) { border-color: #aab4b0; }
.field-group input:focus,
.field-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20,120,111,.1); outline: 0; }
.field-group input:disabled,
.field-group select:disabled { background: var(--surface-strong); color: var(--ink-faint); opacity: .68; }
.field-group--compact { gap: 5px; }
.field-group--compact input,
.field-group--compact select { min-height: 38px; padding-block: 7px; }
.field-help,
.field-error { margin: 0; font-size: .76rem; line-height: 1.42; }
.field-help { color: var(--ink-faint); }
.field-error { min-height: 1em; color: var(--danger); }

.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); margin-top: 28px; padding-top: 20px; }
.form-actions--right { justify-content: flex-end; }

/* Login */
.login-shell { display: grid; min-height: 100dvh; grid-template-columns: minmax(360px,.82fr) minmax(480px,1.18fr); background: var(--surface); }
.login-intro { display: flex; min-height: 100dvh; flex-direction: column; justify-content: space-between; overflow: hidden; background: var(--sidebar); padding: clamp(28px,5vw,72px); color: #fff; }
.login-intro__content { max-width: 610px; margin-block: auto; padding-block: 70px; }
.login-intro__content h1 { max-width: 9.5ch; margin-bottom: 24px; font-size: clamp(3.2rem,7vw,6.8rem); font-weight: 560; letter-spacing: -.065em; }
.login-intro__content > p:last-child { max-width: 45ch; color: #bac4c1; font-size: 1.05rem; }
.login-intro__status { display: flex; align-items: center; gap: 10px; margin-bottom: 0; color: #aeb9b6; font-size: .82rem; }
.login-panel { display: grid; min-height: 100dvh; place-items: center; padding: clamp(24px,7vw,110px); }
.login-panel__inner { width: min(100%,510px); }
.login-heading { margin-bottom: 28px; }
.login-heading h2 { margin-bottom: 12px; font-size: clamp(2.2rem,4vw,3.2rem); }
.login-heading > p:last-child { max-width: 44ch; margin-bottom: 0; color: var(--ink-soft); }
.login-form { display: grid; gap: 18px; animation: fade-rise 380ms var(--ease) both; }
.login-form input { min-height: 54px; font-size: 1.05rem; }
.login-panel__privacy { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 24px 0 0; color: var(--ink-faint); font-size: .73rem; }
.lock-mark { font-size: 1rem; }

/* Admin shell */
.admin-shell { display: grid; min-height: 100dvh; grid-template-columns: 250px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; display: flex; width: 250px; height: 100dvh; flex-direction: column; background: var(--sidebar); padding: 26px 18px 16px; color: #dfe6e3; }
.sidebar__brand { flex: 0 0 auto; padding: 0 10px 28px; }
.sidebar__nav { min-width: 0; min-height: 0; flex: 1 1 auto; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(174,187,183,.5) transparent; }
.sidebar__nav > p { margin: 0 10px 8px; color: #74827d; font-size: .65rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.sidebar__link { display: grid; width: 100%; min-height: 44px; grid-template-columns: 22px minmax(0,1fr) auto; align-items: center; gap: 11px; border: 0; border-radius: var(--radius-sm); margin-bottom: 3px; background: transparent; padding: 10px; color: #aebbb7; font-size: .87rem; font-weight: 590; text-align: left; transition: background-color 180ms var(--ease), color 180ms var(--ease); }
.sidebar__link:hover { background: var(--sidebar-soft); color: #fff; }
.sidebar__link.is-active { background: #30423e; color: #fff; }
.nav-icon { display: grid; width: 22px; height: 22px; place-items: center; color: #78c5bb; font-size: 1.05rem; }
.nav-count { border: 1px solid #48615b; border-radius: 4px; padding: 2px 5px; color: #91c5be; font-family: var(--font-mono); font-size: .62rem; }
.sidebar__footer { display: grid; flex: 0 0 auto; gap: 8px; border-top: 1px solid #34413e; margin-top: auto; padding-top: 14px; }
.connection-state { display: flex; align-items: center; gap: 8px; padding: 4px 10px; color: #899691; font-size: .7rem; }
.identity { display: grid; width: 100%; grid-template-columns: 36px minmax(0,1fr) 16px; align-items: center; gap: 10px; border: 0; border-radius: var(--radius-sm); background: transparent; padding: 8px; color: #fff; text-align: left; }
.identity:hover { background: var(--sidebar-soft); }
.identity > span:nth-child(2),
.identity strong,
.identity small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity strong,
.identity small { display: block; }
.identity strong { font-size: .79rem; }
.identity small { color: #8d9b96; }
.identity__avatar { display: inline-grid; width: 36px; height: 36px; place-items: center; border: 1px solid #48615b; border-radius: 50%; background: #30423e; color: #dceeea; font-size: .68rem; font-weight: 760; letter-spacing: .04em; }
.identity__arrow { color: #71807b; font-size: .9rem; }
.admin-main { min-width: 0; }
.mobile-header { display: none; }
.page-container { width: 100%; max-width: 1440px; min-height: 100dvh; margin: 0 auto; padding: clamp(26px,4vw,68px) clamp(18px,4vw,64px); }
.page-view { display: block; width: 100%; min-width: 0; animation: page-enter 480ms var(--ease) both; }
.page-header { margin-bottom: 30px; }
.page-header--split { display: flex; align-items: center; justify-content: space-between; gap: 18px 28px; flex-wrap: wrap; }
.page-header--split > div:first-child { min-width: 0; max-width: 820px; flex: 1 1 420px; }
.page-header h1 { margin-bottom: 0; font-size: clamp(2.4rem,4vw,4.2rem); line-height: 1.02; }
.page-header .page-lead { max-width: 720px; margin-top: 8px; font-size: .94rem; line-height: 1.4; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.list-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); margin-bottom: 12px; padding: 13px 3px 0; color: var(--ink-faint); font-size: .78rem; }
.list-summary__label { font-weight: 650; }
.list-summary__value { font-family: var(--font-mono); }

/* Notices and states */
.inline-notice,
.inline-error { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-subtle); padding: 13px 15px; color: var(--ink-soft); }
.inline-notice .notice-mark,
.inline-error .notice-mark { display: inline-grid; width: 19px; height: 19px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-size: .75rem; font-weight: 750; }
.inline-error { border-color: #ecc4c1; background: var(--danger-soft); color: var(--danger); }
.inline-error .notice-mark { background: #f2cbc8; color: var(--danger); }
.inline-notice--warning { border-color: #e4d3aa; background: var(--warning-soft); color: var(--warning); }
.inline-notice--warning .notice-mark { background: #f1dfb9; color: var(--warning); }
.readonly-badge { display: inline-flex; min-height: 34px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-subtle); padding: 7px 10px; color: var(--ink-soft); font-size: .75rem; font-weight: 650; white-space: nowrap; }
.empty-state { display: grid; min-height: 320px; place-content: center; justify-items: center; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 30px; text-align: center; }
.empty-state--compact { min-height: 250px; }
.empty-state__icon { display: inline-grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--line); border-radius: 50%; margin-bottom: 16px; background: var(--surface-subtle); color: var(--accent); font-size: 1.3rem; }
.empty-state h2 { margin-bottom: 8px; font-size: 1.3rem; }
.empty-state p { max-width: 48ch; margin-bottom: 18px; color: var(--ink-soft); }
.empty-inline { display: grid; gap: 4px; padding: 20px 4px; color: var(--ink-faint); font-size: .82rem; }
.empty-inline strong { color: var(--ink-soft); font-size: .86rem; }
.empty-inline--error { border: 1px solid #ecc4c1; border-radius: var(--radius-sm); background: var(--danger-soft); padding: 14px; color: var(--danger); }
.empty-inline--error .button { justify-self: start; margin-top: 8px; }
.skeleton-row,
.skeleton-block { position: relative; overflow: hidden; border-radius: var(--radius-md); background: #e7eae6; }
.skeleton-row::after,
.skeleton-block::after,
.catalog-loading span::after { position: absolute; inset: 0; background: rgba(255,255,255,.45); content: ""; transform: translateX(-105%); animation: skeleton-pass 1.7s var(--ease) infinite; }
.skeleton-row { display: grid; min-height: 116px; gap: 10px; padding: 23px; }
.skeleton-row--tenant { min-height: 190px; }
.skeleton-row__line { display: block; width: 48%; height: 12px; border-radius: 4px; background: #dce2dd; }
.skeleton-row__line--long { width: 74%; height: 18px; }
.skeleton-block { min-height: 180px; }

/* Customer list */
.tenant-list { display: grid; gap: 12px; }
.tenant-card { display: grid; grid-template-columns: minmax(0,1fr) auto; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 2px 0 rgba(28,37,35,.02); transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease); }
.tenant-card:hover { border-color: #aab8b1; box-shadow: var(--shadow); transform: translateY(-1px); }
.tenant-card__main { display: block; min-width: 0; border: 0; background: transparent; padding: 22px 23px 20px; text-align: left; }
.tenant-card__heading { display: flex; min-width: 0; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.tenant-card__name { min-width: 0; overflow: hidden; color: var(--ink); font-size: 1.18rem; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.tenant-card__host { margin: 7px 0 18px; overflow: hidden; color: var(--ink-soft); font-family: var(--font-mono); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.tenant-facts { display: flex; flex-wrap: wrap; gap: 14px 28px; margin: 0; }
.tenant-fact { display: grid; gap: 2px; }
.tenant-fact dt { color: var(--ink-faint); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tenant-fact dd { margin: 0; color: var(--ink-soft); font-size: .78rem; }
.tenant-fact dd.is-mono { font-family: var(--font-mono); }
.tenant-card__message { max-width: 78ch; margin: 16px 0 0; color: var(--warning); font-size: .8rem; }
.tenant-card__message.is-error { color: var(--danger); }
.tenant-card__actions { display: flex; min-width: 145px; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 12px; border-left: 1px solid var(--line); padding: 18px; }
.tenant-card__open-hint { color: var(--ink-faint); font-size: .74rem; }
.status-pill,
.token-status { display: inline-flex; width: fit-content; min-height: 26px; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-subtle); padding: 4px 9px; color: var(--ink-faint); font-size: .68rem; font-weight: 720; letter-spacing: .02em; white-space: nowrap; }
.status-pill--ready { border-color: #acd1ca; background: var(--accent-soft); color: var(--accent-strong); }
.status-pill--provisioning { border-color: #e4d3aa; background: var(--warning-soft); color: var(--warning); }
.status-pill--queued { border-color: #cfd7d2; background: #eef1ed; color: var(--ink-soft); }
.status-pill--error { border-color: #e0b5b2; background: var(--danger-soft); color: var(--danger); }

/* Detail */
.detail-header { margin-bottom: 25px; }
.back-link { display: inline-flex; min-height: 36px; align-items: center; gap: 8px; border: 0; margin-bottom: 22px; background: transparent; padding: 0; color: var(--ink-soft); font-size: .82rem; font-weight: 650; }
.back-link:hover { color: var(--accent-strong); }
.detail-header__line { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.detail-header__line h1 { margin-bottom: 8px; font-size: clamp(2rem,4vw,3.45rem); }
.detail-subtitle { margin: 0; color: var(--ink-soft); font-family: var(--font-mono); font-size: .8rem; }
.detail-header__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.detail-grid { display: grid; grid-template-columns: minmax(0,1.16fr) minmax(330px,.84fr); align-items: start; gap: 18px; }
.detail-side { display: grid; gap: 18px; min-width: 0; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 22px; }
.panel__header { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.panel__header > div { min-width: 0; }
.panel__header .eyebrow { margin-bottom: 5px; }
.panel__header h2 { margin-bottom: 0; font-size: 1.35rem; }
.panel__lead { margin: 0 0 19px; color: var(--ink-soft); font-size: .82rem; line-height: 1.48; }
.panel__footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.save-hint { margin: 0; color: var(--ink-faint); font-size: .72rem; }

.station-panel { container: station-panel / inline-size; }
.station-editor { display: grid; max-height: min(50vh, 500px); min-width: 0; gap: 9px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.station-row { display: grid; grid-template-columns: 112px minmax(145px,1fr) minmax(155px,1fr) 100px; align-items: end; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-subtle); padding: 13px; }
.station-toggle { display: flex; min-height: 38px; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .75rem; font-weight: 650; }
.station-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-track { position: relative; display: inline-block; width: 34px; height: 20px; flex: 0 0 auto; border-radius: 999px; background: #b8c2bd; transition: background-color 160ms var(--ease); }
.switch-track::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(23,32,30,.22); content: ""; transition: transform 160ms var(--ease); }
.station-toggle input:checked + .switch-track { background: var(--accent); }
.station-toggle input:checked + .switch-track::after { transform: translateX(14px); }
.station-toggle input:focus-visible + .switch-track { outline: 3px solid rgba(20,120,111,.28); outline-offset: 2px; }
.station-row__identity { min-width: 0; align-self: center; }
.station-row__identity strong,
.station-row__identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-row__identity strong { margin-bottom: 3px; color: var(--ink); font-size: .86rem; }
.station-row__identity small { color: var(--ink-faint); font-family: var(--font-mono); font-size: .66rem; }
.station-row__order input { text-align: right; }
.station-printer-settings { display: flex; min-width: 0; grid-column: 1 / -1; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.station-printer-hint { min-width: 0; overflow: hidden; color: var(--ink-faint); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.station-printer-toggle input:disabled + .switch-track { background: #d1d8d4; }
.station-printer-toggle input:disabled + .switch-track::after { background: #f7f8f7; box-shadow: none; }

@container station-panel (max-width: 560px) {
  .station-row { grid-template-columns: minmax(0,1fr) 84px; gap: 10px; }
  .station-toggle,
  .station-row__identity { grid-column: 1 / -1; }
  .station-row__field { grid-column: 1; }
  .station-row__order { grid-column: 2; }
}

.token-form { display: grid; gap: 14px; }
.token-form .form-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.token-result,
.bootstrap-result { display: grid; gap: 13px; border: 1px solid #acd1ca; border-radius: var(--radius-sm); margin-top: 18px; background: var(--accent-soft); padding: 14px; }
.token-result__heading { display: flex; align-items: flex-start; gap: 10px; }
.token-result__heading strong { display: block; margin-bottom: 3px; color: var(--accent-strong); font-size: .82rem; }
.token-result__heading p { margin: 0; color: var(--ink-soft); font-size: .73rem; line-height: 1.4; }
.success-mark { display: inline-grid; width: 22px; height: 22px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 750; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { min-width: 0; flex: 1; border: 1px solid #a8c9c1; border-radius: var(--radius-sm); background: rgba(255,255,255,.72); padding: 8px 10px; color: var(--accent-strong); font-family: var(--font-mono); font-size: .72rem; }
.copy-field .button { flex: 0 0 auto; }
.bootstrap-result { border-color: #e4d3aa; background: var(--warning-soft); }
.bootstrap-result .token-result__heading strong { color: var(--warning); }
.token-list { display: grid; gap: 8px; }
.token-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 12px 0; }
.token-row:last-child { border-bottom: 0; padding-bottom: 0; }
.token-row:first-child { padding-top: 2px; }
.token-row__identity { min-width: 0; }
.token-row__identity strong,
.token-row__identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-row__identity strong { margin-bottom: 3px; color: var(--ink); font-size: .8rem; }
.token-row__identity small,
.token-row__meta small { color: var(--ink-faint); font-size: .68rem; }
.token-row__meta { display: grid; justify-items: end; gap: 3px; }
.token-status { min-height: 22px; padding: 3px 7px; font-size: .61rem; }
.token-status--active { border-color: #acd1ca; background: var(--accent-soft); color: var(--accent-strong); }
.token-status--revoked,
.token-status--expired { border-color: #e0b5b2; background: var(--danger-soft); color: var(--danger); }
.token-row__revoke { color: var(--danger); }
.token-row__revoke:hover:not(:disabled) { background: var(--danger-soft); }

/* Modal */
.modal-layer { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(19,27,25,.64); }
.modal { position: relative; display: flex; width: min(100%, 680px); max-height: min(88dvh, 900px); flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-high); animation: modal-in 260ms var(--ease) both; }
.modal__header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); padding: 18px 22px; }
.modal__header h2 { margin: 0; font-size: 1.4rem; }
.modal__body { min-height: 0; overflow-y: auto; padding: 22px; }

/* Tenant station catalog */
.catalog-body { background: var(--canvas); }
.station-catalog { width: min(100%, 1080px); min-height: 100dvh; margin: 0 auto; padding: 26px clamp(18px,5vw,60px) 34px; }
.catalog-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; border-radius: var(--radius-md); background: var(--sidebar); padding: 16px 20px; color: #fff; }
.catalog-header__season { color: #91c5be; font-family: var(--font-mono); font-size: .76rem; }
.catalog-intro { padding: clamp(30px,5vw,56px) 3px 24px; }
.catalog-intro h1 { max-width: 28ch; margin-bottom: 10px; font-size: clamp(2rem,3.2vw,2.75rem); line-height: 1.05; }
.catalog-intro .page-lead { font-size: 1.02rem; }
.catalog-state { display: grid; min-height: 220px; place-items: center; }
.catalog-loading { display: grid; width: min(100%, 420px); gap: 10px; }
.catalog-loading span { position: relative; display: block; height: 66px; overflow: hidden; border-radius: var(--radius-md); background: #e7eae6; }
.catalog-loading span:nth-child(2) { width: 90%; }
.catalog-loading span:nth-child(3) { width: 78%; }
.catalog-message { display: grid; justify-items: center; max-width: 480px; margin: 0 auto; text-align: center; }
.catalog-message__icon { display: inline-grid; width: 46px; height: 46px; place-items: center; border: 1px solid var(--line); border-radius: 50%; margin-bottom: 15px; background: var(--surface); color: var(--accent); font-size: 1.2rem; }
.catalog-message h2 { margin-bottom: 7px; font-size: 1.3rem; }
.catalog-message p { margin-bottom: 18px; color: var(--ink-soft); font-size: .87rem; }
.catalog-message--error .catalog-message__icon { border-color: #e0b5b2; background: var(--danger-soft); color: var(--danger); }
.station-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.station-card { display: grid; min-height: 142px; grid-template-columns: 40px minmax(0,1fr) 22px; align-items: center; gap: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 20px; transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease); }
.station-card:hover { border-color: #9fbab3; box-shadow: var(--shadow); transform: translateY(-3px); }
.station-card__index { display: inline-grid; width: 40px; height: 40px; place-items: center; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); font-family: var(--font-mono); font-size: .72rem; }
.station-card__content { min-width: 0; }
.station-card__content strong,
.station-card__content small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-card__content strong { margin-bottom: 5px; color: var(--ink); font-size: 1rem; }
.station-card__content small { color: var(--ink-faint); font-size: .75rem; }
.station-card__arrow { color: var(--accent); font-size: 1.3rem; transition: transform 180ms var(--ease); }
.station-card:hover .station-card__arrow { transform: translateX(3px); }
.catalog-footer { margin-top: 52px; border-top: 1px solid var(--line); padding: 16px 3px 0; color: var(--ink-faint); font-size: .7rem; }

/* Single station wrapper */
.station-body-page { overflow: hidden; background: var(--canvas); }
.station-shell { display: flex; height: 100dvh; min-height: 100dvh; flex-direction: column; }
.station-shell__header { display: flex; min-width: 0; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px 24px; border-bottom: 1px solid var(--line); background: var(--surface); padding: 12px clamp(14px,3vw,34px); }
.station-shell__identity { display: flex; min-width: 0; align-items: center; gap: clamp(14px,3vw,28px); }
.station-shell__back { flex: 0 0 auto; margin: 0; }
.station-shell__title { min-width: 0; }
.station-shell__title .eyebrow { margin-bottom: 3px; }
.station-shell__title h1 { overflow: hidden; margin: 0 0 2px; font-size: clamp(1.35rem,2.4vw,2rem); line-height: 1.05; text-overflow: ellipsis; white-space: nowrap; }
.station-shell__meta { overflow: hidden; margin: 0; color: var(--ink-soft); font-family: var(--font-mono); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.station-shell__actions { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.station-shell__actions .status-pill { flex: 0 0 auto; }
.station-shell__notice { flex: 0 0 auto; margin: 10px 14px 0; }
.station-shell__workspace { display: grid; min-width: 0; min-height: 0; flex: 1 1 auto; grid-template-columns: minmax(0,1fr); gap: 12px; overflow: hidden; padding: 12px 14px 14px; }
.station-shell.printer-open .station-shell__workspace { grid-template-columns: minmax(0,1fr) 340px; }
.station-kassa { position: relative; display: flex; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; box-shadow: var(--shadow); }
.station-frame { display: block; width: 100%; height: 100%; min-height: 0; flex: 1 1 auto; border: 0; background: #fff; }
.station-frame-state { position: absolute; z-index: 1; inset: 0; display: grid; align-content: center; justify-items: center; gap: 7px; padding: 28px; background: var(--surface-subtle); color: var(--ink-soft); text-align: center; }
.station-frame-state strong { color: var(--ink); font-size: 1rem; }
.station-frame-state > span:last-child { max-width: 42ch; font-size: .8rem; }
.station-frame-state__mark { display: inline-grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--accent); font-size: 1.05rem; }
.station-frame-state--error,
.station-frame-state--revoked { background: var(--danger-soft); color: var(--danger); }
.station-frame-state--error strong,
.station-frame-state--revoked strong { color: var(--danger); }
.station-frame-state--error .station-frame-state__mark,
.station-frame-state--revoked .station-frame-state__mark { border-color: #e0b5b2; color: var(--danger); }
.station-printer { display: grid; min-width: 0; min-height: 0; grid-template-rows: auto auto minmax(0,1fr); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 18px; }
.station-shell:not(.printer-open) .station-printer { display: none; }
.station-printer__header { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 10px; }
.station-printer__header .eyebrow { margin-bottom: 4px; }
.station-printer__header h2 { margin: 0; font-size: 1.2rem; }
.station-printer__hint { margin: 10px 0 13px; color: var(--ink-soft); font-size: .76rem; line-height: 1.4; }
.station-printer__state { min-height: 0; }
.printer-state { display: grid; min-height: 160px; align-content: center; justify-items: center; gap: 6px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-subtle); padding: 22px; color: var(--ink-soft); text-align: center; }
.printer-state strong { color: var(--ink); font-size: .84rem; }
.printer-state > span:last-child { font-size: .72rem; }
.printer-state__mark { display: inline-grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--accent); font-size: .9rem; }
.printer-state--error { border-style: solid; border-color: #e0b5b2; background: var(--danger-soft); color: var(--danger); }
.printer-state--error strong { color: var(--danger); }
.printer-state--error .printer-state__mark { border-color: #e0b5b2; color: var(--danger); }
.printer-jobs { display: grid; min-height: 0; align-content: start; gap: 10px; overflow-y: auto; padding-right: 3px; }
.printer-job { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-subtle); padding: 10px; }
.printer-job__header { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 8px; }
.printer-job__header strong { min-width: 0; overflow: hidden; color: var(--ink); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.printer-job__header small { flex: 0 0 auto; color: var(--ink-faint); font-size: .63rem; }
.printer-job__image { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.printer-job__fallback { display: grid; min-height: 92px; place-items: center; border: 1px dashed var(--line-strong); border-radius: 4px; color: var(--ink-faint); font-size: .72rem; text-align: center; }

.noscript-message { display: grid; min-height: 100dvh; place-content: center; padding: 30px; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes page-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes skeleton-pass { to { transform: translateX(105%); } }
@keyframes status-breathe { 0%,100% { box-shadow: 0 0 0 0 rgba(81,182,168,.18); } 45% { box-shadow: 0 0 0 5px rgba(81,182,168,0); } }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0,1fr); }
  .detail-side { grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
}

@media (max-width: 840px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 230px; padding: 26px 24px; }
  .login-intro__content { margin: 0; padding: 42px 0 20px; }
  .login-intro__content h1 { max-width: 12ch; margin-bottom: 11px; font-size: clamp(2.5rem,9vw,4.4rem); }
  .login-intro__content > p:last-child { margin-bottom: 0; font-size: .9rem; }
  .login-panel { min-height: auto; padding: 48px 24px 60px; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; height: auto; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto auto; gap: 10px 18px; padding: 15px 18px; }
  .sidebar__brand { padding: 0; }
  .sidebar__nav { grid-column: 1 / -1; grid-row: 2; overflow: visible; }
  .sidebar__nav > p { display: none; }
  .sidebar__link { width: fit-content; min-height: 38px; margin: 0; padding: 7px 10px; }
  .sidebar__footer { display: flex; align-items: center; gap: 12px; border-top: 0; margin: 0; padding: 0; }
  .connection-state { display: none; }
  .identity { width: auto; grid-template-columns: 30px 16px; padding: 0; }
  .identity__avatar { width: 30px; height: 30px; }
  .identity > span:nth-child(2) { display: none; }
  .identity__arrow { font-size: .85rem; }
  .page-container { padding: 32px 22px 48px; }
  .mobile-header { display: none; }
}

@media (max-width: 640px) {
  .page-container { padding: 26px 16px 38px; }
  .page-header { margin-bottom: 24px; }
  .page-header--split { align-items: flex-start; }
  .page-header--split > div:first-child { flex-basis: 100%; }
  .header-actions { width: 100%; justify-content: stretch; }
  .header-actions .button { flex: 1 1 0; }
  .tenant-card { grid-template-columns: 1fr; }
  .tenant-card__main { padding: 18px; }
  .tenant-card__actions { min-width: 0; flex-direction: row; align-items: center; border-top: 1px solid var(--line); border-left: 0; padding: 12px 18px; }
  .detail-header__line { align-items: flex-start; flex-direction: column; }
  .detail-header__actions { justify-content: flex-start; }
  .detail-side { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .panel__footer { align-items: stretch; flex-direction: column; }
  .panel__footer .button { width: 100%; }
  .station-row { grid-template-columns: minmax(0,1fr) 84px; align-items: end; gap: 10px; }
  .station-toggle { grid-column: 1 / -1; }
  .station-row__identity { grid-column: 1 / -1; }
  .station-row__field { grid-column: 1; }
  .station-row__order { grid-column: 2; }
  .token-form .form-grid { grid-template-columns: minmax(0,1fr); }
  .token-row { grid-template-columns: minmax(0,1fr) auto; }
  .token-row__meta { justify-items: end; }
  .token-row__revoke { grid-column: 1 / -1; justify-self: start; padding-left: 0; }
  .modal-layer { padding: 0; }
  .modal { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .modal__body { padding: 20px 18px 28px; }
  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .form-grid__wide { grid-column: auto; }
  .form-actions { margin-top: 22px; }
  .station-grid { grid-template-columns: 1fr; }
  .catalog-intro { padding-top: 42px; }
  .catalog-intro h1 { max-width: 20ch; }
}

@media (max-width: 420px) {
  .sidebar { padding-inline: 14px; }
  .sidebar__brand .brand { font-size: .92rem; }
  .sidebar__brand .brand__mark { width: 26px; height: 26px; }
  .page-header h1 { font-size: 2.45rem; }
  .header-actions { flex-direction: column; }
  .header-actions .button { width: 100%; }
  .copy-field { align-items: stretch; flex-direction: column; }
  .copy-field .button { width: 100%; }
  .catalog-header { padding: 14px; }
  .catalog-header .brand { font-size: .88rem; }
  .catalog-header .brand__mark--large { width: 36px; height: 36px; gap: 3px; }
  .station-card { min-height: 124px; padding: 16px; }
}

@media (max-width: 760px) {
  .station-body-page { overflow: auto; }
  .station-shell { height: auto; min-height: 100dvh; }
  .station-shell__header { align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; }
  .station-shell__identity { width: 100%; align-items: flex-start; flex-direction: column; gap: 5px; }
  .station-shell__title h1 { overflow: visible; white-space: normal; }
  .station-shell__actions { width: 100%; justify-content: flex-start; }
  .station-shell__workspace { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
  .station-kassa { min-height: min(66dvh, 520px); flex: 1 1 auto; }
  .station-shell.printer-open .station-kassa { min-height: 240px; }
  .station-printer { max-height: min(36dvh, 300px); flex: 0 0 min(36dvh, 300px); padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.clipboard-helper { position: fixed; opacity: 0; pointer-events: none; }
