:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f2f3f5;
  --ink: #1f2329;
  --muted: #86909c;
  --line: #edf0f5;
  --line-strong: #dfe3ea;
  --blue: #165dff;
  --blue-dark: #0e42d2;
  --blue-soft: #e8f3ff;
  --green: #00b42a;
  --green-soft: #e8ffea;
  --gold: #ffb400;
  --gold-soft: #fff7e8;
  --red: #f53f3f;
  --red-soft: #ffece8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(31, 35, 41, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

[hidden] {
  display: none !important;
}

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

body {
  background:
    radial-gradient(circle at 78% 0%, rgba(22, 93, 255, 0.08), transparent 30%),
    radial-gradient(circle at 0% 42%, rgba(20, 201, 201, 0.08), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, "Microsoft YaHei", Arial, sans-serif;
  margin: 0;
}

body.app-body {
  overflow: hidden;
}

a {
  color: var(--blue);
  text-decoration: none;
}

button,
.button {
  align-items: center;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  gap: 6px;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
}

button:hover,
.button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #cbd5df;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  padding: 9px 10px;
  width: 100%;
}

input::placeholder {
  color: #a9aeb8;
}

table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fafafa;
  color: #4e5969;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f7fbff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.text-link {
  color: var(--blue);
  font-weight: 650;
}

.primary-action {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.secondary-action {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--ink);
}

.danger-button {
  background: var(--red);
  border-color: var(--red);
}

.app-topbar,
.public-topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 64px;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left,
.topbar-actions,
.topbar-brand,
.company-chip,
.company-toolbar,
.language-switcher {
  align-items: center;
  display: flex;
}

.topbar-left {
  gap: 28px;
}

.topbar-brand {
  color: var(--ink);
  gap: 11px;
}

.topbar-brand strong {
  display: block;
  font-size: 24px;
  font-weight: 760;
  line-height: 1;
}

.brand-copy {
  align-items: center;
  display: flex;
}

.brand-mark {
  background: #050505;
  border-radius: 12px;
  color: #ffffff;
  display: grid;
  height: 42px;
  place-items: center;
  width: 42px;
}

.hurtik-logo-mark span {
  color: #ffffff;
  font-size: 12px;
  font-style: italic;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  transform: skew(-7deg);
}

.brand-mark svg,
.icon-button svg,
.side-nav svg,
.sync-card svg,
.console-control svg {
  height: 16px;
  width: 16px;
}

.topbar-actions {
  gap: 10px;
}

.icon-button,
.language-switcher,
.company-chip,
.logout-form button {
  background: var(--surface-muted);
  border: 0;
  border-radius: 999px;
  color: #4e5969;
  min-height: 36px;
  padding: 0 12px;
}

.icon-button {
  display: grid;
  padding: 0;
  place-items: center;
  width: 36px;
}

.language-switcher {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(31, 35, 41, 0.04);
  min-height: 36px;
  position: relative;
  z-index: 90;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.language-switcher:hover,
.language-switcher[open] {
  border-color: #c9d7ee;
  box-shadow: 0 8px 18px rgba(31, 35, 41, 0.08);
}

.language-switcher summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 7px;
  list-style: none;
  min-height: 34px;
  padding: 0 30px 0 12px;
  user-select: none;
}

.language-switcher summary::-webkit-details-marker {
  display: none;
}

.language-switcher span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.language-menu {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(31, 35, 41, .16);
  display: grid;
  gap: 4px;
  min-width: 132px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 80;
}

.language-menu button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: flex-start;
  min-height: 32px;
  padding: 0 10px;
  text-align: left;
  width: 100%;
}

.language-menu button:hover,
.language-menu button.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.language-switcher[open] summary::after {
  transform: translateY(-28%) rotate(225deg);
}

.company-chip {
  gap: 8px;
}

.company-toolbar {
  gap: 8px;
}

.current-company-chip {
  background: var(--blue-soft);
  color: var(--blue);
}

.company-missing-chip {
  background: var(--gold-soft);
  color: #b27700;
  font-weight: 700;
}

.company-add-link {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
  padding: 8px 12px;
}

.company-add-link:hover {
  background: var(--surface-muted);
}

.avatar-dot {
  background: var(--gold);
  border-radius: 999px;
  color: #ffffff;
  display: grid;
  font-size: 12px;
  height: 22px;
  place-items: center;
  width: 22px;
}

.logout-form {
  display: inline;
}

.logout-form button {
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: calc(100vh - 64px);
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.sidebar {
  background: rgba(255, 255, 255, 0.98);
  border-right: 1px solid var(--line);
  color: var(--ink);
  height: calc(100vh - 64px);
  min-height: 0;
  overflow: hidden;
  padding: 48px 12px 20px;
  position: sticky;
  top: 64px;
}

.company-card,
.sync-card {
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
  padding: 16px;
}

.company-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-company-switch-form {
  min-width: 0;
  position: relative;
  width: 100%;
}

.sidebar-company-switch-form select {
  appearance: none;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
  max-width: 100%;
  min-height: 34px;
  padding: 6px 30px 6px 10px;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.sidebar-company-switch-form::after,
.language-switcher summary::after {
  border-bottom: 1.6px solid currentColor;
  border-right: 1.6px solid currentColor;
  content: "";
  height: 6px;
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-62%) rotate(45deg);
  width: 6px;
}

.sidebar-company-switch-form select:hover,
.sidebar-company-switch-form select:focus {
  border-color: #c9d7ee;
  box-shadow: 0 0 0 3px rgba(22, 93, 255, .08);
  outline: none;
}

.company-card-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.company-card-title em {
  background: var(--blue);
  border-radius: 999px;
  color: #ffffff;
  flex: 0 0 auto;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  padding: 3px 7px;
}

.company-card span,
.sync-card span,
.nav-label {
  color: var(--muted);
  font-size: 13px;
}

.current-company-card {
  background: #f1f7ff;
  border-color: #cce2ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.current-company-card a {
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  margin-top: 10px;
}

.company-card-missing {
  background: var(--gold-soft);
  border-color: #ffd591;
  color: var(--ink);
  display: block;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.nav-label {
  font-weight: 650;
  margin: 10px 0 2px;
  padding: 0 12px;
}

.side-nav a {
  align-items: center;
  border-radius: 10px;
  color: #4e5969;
  display: flex;
  font-size: 15px;
  font-weight: 650;
  gap: 10px;
  padding: 10px 14px;
  position: relative;
}

.side-nav a:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.side-nav a.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.side-nav a.active::before {
  background: var(--blue);
  border-radius: 999px;
  bottom: 9px;
  content: "";
  left: -8px;
  position: absolute;
  top: 9px;
  width: 3px;
}

.sync-card {
  align-items: center;
  bottom: 20px;
  display: flex;
  gap: 12px;
  left: 20px;
  margin: 0;
  position: absolute;
  right: 20px;
}

.sync-card strong {
  display: block;
  font-size: 14px;
}

.main-shell {
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.page {
  height: 100%;
  margin: 0;
  max-width: none;
  overflow: auto;
  padding: 16px 24px 28px;
}

.page:has(.invoice-table-panel),
.page:has(.daily-report-panel),
.page:has(.replenishment-panel) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.page:has(.invoice-table-panel) .client-header,
.page:has(.daily-report-panel) .client-header,
.page:has(.replenishment-panel) .client-header,
.page:has(.invoice-table-panel) .invoice-filter-panel {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.page:has(.invoice-table-panel) .invoice-table-panel,
.page:has(.daily-report-panel) .daily-report-panel,
.page:has(.replenishment-panel) .replenishment-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.panel,
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.message-modal,
.download-modal {
  align-items: center;
  background: rgba(15, 23, 42, .36);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 22px;
  position: fixed;
  z-index: 100;
}

.message-modal-card,
.download-modal-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(31, 35, 41, .22);
  max-width: 460px;
  padding: 22px;
  width: min(100%, 460px);
}

.message-modal-card h2,
.download-modal-card h2 {
  font-size: 20px;
  margin: 0 0 10px;
}

.message-text,
.download-modal-card p {
  color: #4e5969;
  line-height: 1.65;
  margin: 0 0 18px;
}

.message-text.error {
  color: #b42318;
}

.message-text.success {
  color: #067647;
}

.message-text.warning {
  color: #b27700;
}

.empty-state-panel {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  justify-content: center;
  min-height: 380px;
  padding: 48px 20px;
  text-align: center;
}

.empty-state-panel h1 {
  font-size: 30px;
  margin: 8px 0 10px;
}

.empty-state-panel p:not(.eyebrow) {
  color: var(--muted);
  margin: 0 auto 22px;
}

.ksef-config-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(320px, 4fr) minmax(0, 6fr);
}

.ksef-config-card,
.usage-guide-panel {
  margin-bottom: 22px;
}

.ksef-config-card {
  padding: 16px;
}

.ksef-config-card .form {
  gap: 12px;
}

.ksef-config-card .form-section {
  gap: 10px;
  padding-bottom: 14px;
}

.ksef-config-card .form-grid-single {
  grid-template-columns: 1fr;
}

.ksef-config-card .ksef-company-fields {
  padding-top: 2px;
}

.ksef-config-card .form-section h2,
.usage-guide-panel h2 {
  font-size: 16px;
}

.usage-guide-panel {
  min-height: 100%;
}

.usage-guide-content {
  background:
    linear-gradient(180deg, rgba(47, 124, 246, .08), rgba(32, 201, 151, .05)),
    var(--surface-muted);
  border: 1px solid #dbe6f5;
  border-radius: var(--radius-sm);
  color: #2b3440;
  display: grid;
  gap: 14px;
  line-height: 1.65;
  padding: 16px 18px;
}

.usage-guide-content ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.usage-guide-content li::marker {
  color: var(--blue);
  font-weight: 800;
}

.usage-guide-note {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 12px;
}

.usage-guide-images {
  display: grid;
  gap: 12px;
}

.usage-guide-images img {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(21, 34, 56, .08);
  display: block;
  height: auto;
  max-width: 100%;
  width: 100%;
}

.auth-panel {
  box-shadow: var(--shadow);
  margin: 80px auto;
  max-width: 420px;
}

.auth-subtitle,
.auth-switch {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.auth-subtitle {
  margin: -4px 0 18px;
}

.auth-switch {
  margin: 16px 0 0;
  text-align: center;
}

.auth-switch a {
  color: var(--blue);
  font-weight: 750;
}

.locked-panel {
  margin: 0 auto;
  max-width: 760px;
  padding: 28px;
}

.locked-panel h1 {
  font-size: 28px;
  margin: 8px 0 10px;
}

.locked-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.7;
}

.client-header,
.ops-header,
.page-heading,
.section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.client-header,
.ops-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.client-header h1,
.ops-header h1,
.page-heading h1 {
  font-size: 30px;
  line-height: 1.15;
  margin: 4px 0 0;
}

.client-header p,
.ops-header p,
.page-heading p,
.section-title p {
  color: var(--muted);
  margin: 0;
}

.eyebrow {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.invoice-title-grid {
  align-items: center;
  column-gap: 14px;
  display: grid;
  grid-template-columns: minmax(190px, max-content) max-content minmax(360px, 1fr) max-content;
  grid-template-rows: auto auto;
  min-width: 0;
  row-gap: 6px;
  width: 100%;
}

.invoice-title-grid .eyebrow {
  grid-column: 1;
  grid-row: 1;
}

.invoice-title-grid h1 {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
}

.console-toolbar,
.invoice-filter-form,
.period-form {
  align-items: center;
  display: grid;
  gap: 10px;
}

.invoice-filter-form {
  grid-template-columns: minmax(360px, 1.5fr) minmax(170px, .55fr) minmax(170px, .55fr) auto;
}

.period-form {
  grid-template-columns: minmax(90px, 120px) minmax(80px, 100px) auto;
}

.period-inline-form {
  align-items: center;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid #dfe7f3;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(21, 34, 56, .08);
  display: inline-grid;
  gap: 8px;
  grid-template-columns: 108px auto 78px auto;
  min-height: 58px;
  padding: 9px 12px;
}

.period-inline-form:focus-within {
  border-color: #8bb8ff;
  box-shadow: 0 0 0 4px rgba(47, 124, 246, .12), 0 12px 28px rgba(21, 34, 56, .10);
}

.period-inline-form select {
  appearance: none;
  -webkit-appearance: none;
  background-color: #ffffff;
  border: 1px solid #d9e3f2;
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
  font-weight: 760;
  min-height: 38px;
  outline: none;
  padding: 0 30px 0 12px;
  text-align: right;
  width: 100%;
}

.period-inline-form select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--blue) 50%),
    linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 54%,
    calc(100% - 9px) 54%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
}

.period-inline-form select:hover {
  border-color: #b8cff5;
  color: var(--blue);
}

.period-inline-form select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 124, 246, .12);
}

.period-inline-form option {
  background: #ffffff;
  color: var(--ink);
  font-size: 15px;
}

.period-inline-form span {
  color: var(--ink);
  font-size: 18px;
  font-weight: 780;
}

.console-control,
.invoice-filter-form label,
.period-form input,
.period-form select {
  align-items: center;
  background: var(--surface-muted);
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
}

.invoice-filter-form label {
  font-size: 0;
}

.invoice-filter-form label input,
.period-form input,
.period-form select,
.console-control input {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  padding: 0;
}

.date-control {
  cursor: pointer;
}

.date-control input {
  cursor: pointer;
}

.filter-actions,
.ops-actions,
.ksef-action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-action svg {
  height: 15px;
  width: 15px;
}

.export-action,
.note-preset-menu summary {
  box-shadow: 0 1px 2px rgba(29, 33, 41, .04);
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.export-action:hover,
.note-preset-menu summary:hover {
  transform: translateY(-1px);
}

.export-pdf-action {
  background: #e8f7f0;
  border-color: #bce7d0;
  color: #067647;
}

.export-pdf-action:hover {
  background: #d7f2e6;
  border-color: #93d8b7;
  color: #05603a;
}

.export-xml-action {
  background: #eef4ff;
  border-color: #c7d7fe;
  color: #1d4ed8;
}

.export-xml-action:hover {
  background: #dfeaff;
  border-color: #a8c0ff;
  color: #1e40af;
}

.export-xlsx-action {
  background: #fff3e0;
  border-color: #ffd79a;
  color: #b45309;
}

.export-xlsx-action:hover {
  background: #ffe8c2;
  border-color: #ffc46b;
  color: #92400e;
}

.invoice-sync-form {
  display: contents;
}

.invoice-sync-status {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
}

.invoice-xml-cache-status {
  background: #eef4ff;
  color: #1d4ed8;
  grid-column: 2;
  grid-row: 2;
  justify-self: start;
}

.invoice-sync-button {
  grid-column: 4;
  grid-row: 1 / span 2;
  justify-self: end;
}

.invoice-cache-card {
  align-self: stretch;
  background: #f8fbff;
  border: 1px solid #d8e6ff;
  border-radius: 12px;
  color: #355071;
  grid-column: 3;
  grid-row: 1 / span 2;
  min-width: 0;
  padding: 10px 12px;
}

.invoice-cache-card.ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.invoice-cache-card.waiting,
.invoice-cache-card.warning {
  background: #fff8eb;
  border-color: #fed7aa;
  color: #9a5a00;
}

.invoice-cache-card.muted {
  background: #f6f7f9;
  border-color: var(--line-strong);
  color: #4e5969;
}

.invoice-cache-card-main {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.invoice-cache-card-main strong {
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.invoice-cache-card-main span:last-child {
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  margin-left: auto;
  white-space: nowrap;
}

.cache-live-dot {
  background: #2563eb;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.invoice-cache-card.ok .cache-live-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(0, 180, 42, .12);
}

.invoice-cache-card.waiting .cache-live-dot,
.invoice-cache-card.warning .cache-live-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 180, 0, .18);
}

.invoice-cache-card.syncing .cache-live-dot {
  animation: cachePulse 1.5s ease-in-out infinite;
}

.invoice-cache-progress {
  background: rgba(22, 93, 255, .1);
  border-radius: 999px;
  height: 5px;
  margin: 8px 0 7px;
  overflow: hidden;
}

.invoice-cache-card.ok .invoice-cache-progress {
  background: rgba(0, 180, 42, .14);
}

.invoice-cache-card.waiting .invoice-cache-progress,
.invoice-cache-card.warning .invoice-cache-progress {
  background: rgba(255, 180, 0, .16);
}

.invoice-cache-progress span {
  background: currentColor;
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 3px;
}

.invoice-cache-card p {
  color: inherit;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

@keyframes cachePulse {
  0%,
  100% {
    opacity: .55;
    transform: scale(.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.invoice-filter-panel {
  margin-bottom: 0;
  padding: 16px;
}

.invoice-table-panel {
  padding: 0;
}

.page-size-control {
  min-width: 112px;
}

.pagination-page-size-form {
  margin: 0;
}

.pagination-page-size-control {
  min-height: 34px;
}

.invoice-no-company-state {
  align-items: center;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  justify-content: center;
  padding: 42px 20px;
  text-align: center;
}

.invoice-no-company-state h2 {
  font-size: 24px;
  margin: 6px 0 10px;
}

.invoice-no-company-state p:not(.eyebrow) {
  color: var(--muted);
  margin: 0 0 20px;
}

.invoice-table-scroll {
  border-radius: var(--radius);
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.invoice-pagination {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex: 0 0 auto;
  font-size: 13px;
  justify-content: space-between;
  padding: 12px 16px;
}

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

.invoice-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.daily-report-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 16px;
}

.daily-report-heading {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.daily-report-heading h2 {
  font-size: 20px;
  margin: 0;
}

.daily-report-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.daily-report-summary article {
  background: #f7fbff;
  border: 1px solid #d8e6ff;
  border-radius: 12px;
  padding: 10px 12px;
}

.daily-report-summary span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.daily-report-summary strong {
  color: var(--ink);
  font-size: 18px;
}

.daily-report-grid-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.daily-report-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.daily-report-table {
  min-width: 880px;
  table-layout: fixed;
}

.daily-report-col-date {
  width: 132px;
}

.daily-report-col-money {
  width: 15%;
}

.daily-report-col-note {
  width: 170px;
}

.daily-report-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.daily-report-table th,
.daily-report-table td {
  padding: 7px 8px;
}

.daily-report-money-header {
  text-align: right;
}

.daily-report-table input {
  border-color: transparent;
  min-height: 30px;
  padding: 5px 7px;
  text-align: right;
}

.daily-report-table tbody tr:hover input {
  border-color: #cbd5df;
}

.daily-report-table td:last-child input {
  text-align: left;
}

.daily-report-notes-header {
  text-align: center;
}

.daily-report-date-cell {
  color: #4e5969;
  font-weight: 650;
  white-space: nowrap;
}

.daily-report-vat-total {
  color: #4e5969;
  font-weight: 650;
  text-align: right;
}

.daily-report-actions {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
}

.daily-report-actions span {
  background: var(--surface-muted);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
}

.daily-report-actions span[data-state="saving"] {
  background: var(--blue-soft);
  color: var(--blue);
}

.daily-report-actions span[data-state="saved"] {
  background: var(--green-soft);
  color: var(--green);
}

.daily-report-actions span[data-state="error"] {
  background: var(--red-soft);
  color: var(--red);
}

.daily-report-row-error {
  box-shadow: inset 3px 0 0 var(--red);
}

.replenishment-panel {
  gap: 10px;
  padding: 14px;
}

.replenishment-generator-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(150px, .8fr) minmax(150px, .8fr) minmax(130px, .6fr) minmax(130px, .6fr) auto;
}

.replenishment-generator-form label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.replenishment-toolbar {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.replenishment-toolbar strong {
  color: var(--ink);
  font-size: 15px;
  margin-left: auto;
}

.replenishment-toolbar form {
  margin: 0;
}

.replenishment-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.replenishment-table {
  font-size: 12.5px;
  min-width: 900px;
  table-layout: fixed;
}

.replenishment-table thead th {
  position: sticky;
  padding: 6px 8px;
  top: 0;
  z-index: 2;
}

.replenishment-table td {
  padding: 4px 8px;
}

.replenishment-table th:not(:nth-child(2)),
.replenishment-table td:not(:nth-child(2)) {
  text-align: right;
}

.replenishment-col-index {
  width: 70px;
}

.replenishment-col-name {
  width: 34%;
}

.replenishment-col-quantity,
.replenishment-col-price,
.replenishment-col-vat,
.replenishment-col-amount {
  width: 14%;
}

.replenishment-col-action {
  width: 90px;
}

.replenishment-table input {
  border-color: transparent;
  min-height: 26px;
  padding: 3px 6px;
}

.replenishment-table td:not(:nth-child(2)) input,
.replenishment-amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.replenishment-table tbody tr:hover input {
  border-color: #cbd5df;
}

.replenishment-table tfoot td {
  border-bottom: 0;
  padding: 9px 8px;
  text-align: left;
}

.invoice-table {
  font-size: 13px;
  min-width: 1200px;
  table-layout: fixed;
}

.invoice-table th,
.invoice-table td {
  padding: 9px 12px;
}

.invoice-table th {
  font-size: 12px;
}

.invoice-col-number {
  width: 255px;
}

.invoice-col-date {
  width: 105px;
}

.invoice-col-party {
  width: 300px;
}

.invoice-col-nip {
  width: 88px;
}

.invoice-col-money {
  width: 82px;
}

.invoice-col-note {
  width: 160px;
}

.invoice-number-wrap {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.invoice-number-text {
  color: var(--ink);
  font-weight: 750;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invoice-file-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.invoice-file-chip {
  border-radius: 7px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 7px;
}

.invoice-file-chip.pdf {
  background: #e8f7f0;
  color: #0a8f4d;
}

.invoice-file-chip.pdf:hover {
  background: #d7f2e6;
}

.invoice-file-chip.xlsx {
  background: #eaf3ff;
  color: #1f6feb;
}

.invoice-file-chip.xlsx:hover {
  background: #d8eaff;
}

.invoice-file-chip.xml {
  background: #eef1f5;
  color: #4e5969;
}

.invoice-file-chip.xml:hover {
  background: #dfe4eb;
  color: var(--ink);
}

.invoice-file-chip.disabled {
  cursor: not-allowed;
  opacity: .45;
}

.invoice-file-chip.is-busy {
  cursor: wait;
  opacity: .62;
  pointer-events: none;
}

.note-preset-menu {
  position: relative;
}

.note-preset-menu summary {
  align-items: center;
  background: #f3edff;
  border: 1px solid #d9c7ff;
  border-radius: var(--radius-sm);
  color: #6d28d9;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 650;
  min-height: 34px;
  padding: 0 14px;
}

.note-preset-menu summary:hover {
  background: #eadcff;
  border-color: #c4a7ff;
  color: #5b21b6;
}

.note-preset-menu summary::-webkit-details-marker {
  display: none;
}

.note-preset-popover {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  min-width: 280px;
  padding: 12px;
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 30;
}

.note-preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 138px;
  overflow: auto;
}

.note-preset-chip {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4e5969;
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
  min-height: 28px;
  padding: 0 6px 0 10px;
}

.note-preset-chip button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: #86909c;
  font-size: 16px;
  line-height: 1;
  min-height: 20px;
  padding: 0;
  width: 20px;
}

.note-preset-chip button:hover {
  background: var(--red-soft);
  color: var(--red);
}

.note-preset-add {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.note-preset-add input {
  min-height: 34px;
}

.invoice-table th:nth-child(5),
.invoice-table th:nth-child(6),
.invoice-table th:nth-child(7),
.invoice-table td:nth-child(5),
.invoice-table td:nth-child(6),
.invoice-table td:nth-child(7) {
  text-align: right;
  white-space: nowrap;
}

.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2),
.invoice-table th:nth-child(8),
.invoice-table td:nth-child(8) {
  white-space: nowrap;
}

.invoice-number-cell,
.invoice-nip-cell,
.invoice-money-cell,
.invoice-date-cell,
.invoice-note-cell {
  white-space: nowrap;
}

.invoice-number-text,
.invoice-party-cell,
.invoice-note-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

.invoice-party-cell {
  max-width: 300px;
}

.invoice-note-cell {
  color: #4e5969;
  max-width: 160px;
}

.invoice-money-cell,
.invoice-table th:nth-child(5),
.invoice-table th:nth-child(6),
.invoice-table th:nth-child(7) {
  text-align: right;
}

.invoice-note-heading {
  text-align: center;
}

.invoice-note-editor {
  position: relative;
}

.invoice-note-select,
.invoice-note-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #4e5969;
  font-size: 13px;
  min-height: 28px;
  padding: 4px 8px;
}

.invoice-note-select:hover,
.invoice-note-select:focus,
.invoice-note-input:focus {
  background: #ffffff;
  border-color: var(--line-strong);
  outline: none;
}

.invoice-note-editor.saving::after {
  animation: note-spin .75s linear infinite;
  border: 2px solid #dfe3ea;
  border-top-color: var(--blue);
  border-radius: 999px;
  content: "";
  height: 12px;
  position: absolute;
  right: 6px;
  top: 8px;
  width: 12px;
}

.note-toast {
  background: #1f2329;
  border-radius: 10px;
  bottom: 22px;
  box-shadow: var(--shadow);
  color: #ffffff;
  font-size: 13px;
  font-weight: 650;
  padding: 10px 14px;
  position: fixed;
  right: 24px;
  z-index: 80;
}

.note-toast.error {
  background: var(--red);
}

.download-modal {
  align-items: center;
  background: rgba(29, 33, 41, .42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 100;
}

.download-modal[hidden] {
  display: none;
}

.download-modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 22px;
  width: 100%;
}

.download-modal-card h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

.download-modal-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 18px;
}

.download-progress {
  background: #eef2f7;
  border-radius: 999px;
  height: 8px;
  margin: 0 0 18px;
  overflow: hidden;
  position: relative;
}

.download-progress span {
  animation: download-progress 1.15s ease-in-out infinite;
  background: linear-gradient(90deg, #2f7cf6, #20c997);
  border-radius: inherit;
  display: block;
  height: 100%;
  position: absolute;
  width: 42%;
}

.download-progress-text {
  color: #1d2129;
  display: block;
  font-size: 13px;
  margin: -8px 0 18px;
  text-align: center;
}

@keyframes download-progress {
  0% {
    left: -45%;
  }
  100% {
    left: 105%;
  }
}

.export-date-card {
  max-width: 520px;
}

.export-date-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin: 18px 0;
}

.export-date-grid label {
  color: #4e5969;
  display: grid;
  font-size: 13px;
  font-weight: 650;
  gap: 8px;
}

.export-date-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes note-spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-table-cell {
  color: var(--muted);
  padding: 34px 16px;
  text-align: center;
}

.client-metrics,
.metrics,
.ops-metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}

.client-metrics article,
.metrics article,
.ops-metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.client-metrics span,
.metrics span,
.ops-metrics span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.client-metrics strong,
.metrics strong,
.ops-metrics strong {
  font-size: 24px;
}

.columns,
.client-grid,
.ops-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.vat-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 22px;
}

.vat-detail-panel {
  display: grid;
  gap: 16px;
}

.vat-hero.compact {
  margin-bottom: 0;
}

.vat-detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.vat-detail-card {
  margin: 0;
}

.vat-detail-card table td {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.vat-amount span {
  color: var(--muted);
  display: block;
  font-size: 14px;
  margin-bottom: 12px;
}

.vat-amount strong {
  color: var(--blue);
  display: block;
  font-size: 42px;
  line-height: 1;
}

.hero-actions {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.status-pill,
.status-dot {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  padding: 6px 9px;
}

.status-pill.ok,
.status-dot.active {
  background: var(--green-soft);
  color: #008a22;
}

.status-pill.warning,
.status-dot.paused,
.status-dot.warning,
.status-dot.risk-medium {
  background: var(--gold-soft);
  color: #b27700;
}

.status-pill.danger,
.status-dot.risk-high {
  background: var(--red-soft);
  color: var(--red);
}

.status-dot.risk-low {
  background: var(--surface-muted);
  color: var(--muted);
}

.status-dot.expired {
  background: var(--red-soft);
  color: var(--red);
}

.alert-panel {
  border-color: #ffd591;
  margin-bottom: 16px;
}

.date-list,
.ops-actions,
.ops-command-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ops-filter-panel {
  margin-bottom: 16px;
  padding: 14px;
}

.ops-filter-form {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 190px) minmax(150px, 190px) auto auto;
}

.ops-filter-form select {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  width: 100%;
}

.date-list span {
  background: var(--gold-soft);
  border-radius: 999px;
  color: #b27700;
  padding: 6px 10px;
}

.ops-error-cell {
  max-width: 360px;
}

.ops-error-cell summary {
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
}

.ops-error-cell pre {
  background: #fff7f7;
  border: 1px solid #ffd0d0;
  border-radius: 10px;
  color: #7f1d1d;
  font-size: 12px;
  line-height: 1.45;
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.form {
  display: grid;
  gap: 14px;
}

.form-section {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  padding-bottom: 18px;
}

.form-section h2 {
  font-size: 18px;
  margin: 0;
}

.form-grid,
.rate-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rate-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entry-panel,
.invoice-entry {
  margin-bottom: 22px;
}

.sticky-actions {
  align-items: center;
  background: var(--surface);
  bottom: 0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 14px;
}

.danger-inline-form {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
  text-align: right;
}

.checkbox-line {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checkbox-line input {
  width: auto;
}

.form div,
.form label {
  display: grid;
  gap: 6px;
}

.mobile-nav {
  display: none;
}

@media (max-width: 920px) {
  .app-topbar,
  .public-topbar {
    padding: 0 12px;
  }

  .sidebar,
  .topbar-actions .logout-form {
    display: none;
  }

  .app-shell {
    display: block;
    height: calc(100vh - 64px);
    overflow: hidden;
  }

  .page {
    height: 100%;
    overflow: auto;
    padding: 16px 14px 82px;
  }

  .client-header,
  .ops-header,
  .page-heading,
  .section-title,
  .vat-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-page-header {
    gap: 14px;
  }

  .invoice-title-grid {
    grid-template-columns: 1fr;
  }

  .invoice-title-grid .eyebrow,
  .invoice-title-grid h1,
  .invoice-sync-status,
  .invoice-xml-cache-status,
  .invoice-cache-card,
  .invoice-sync-button {
    grid-column: 1;
    justify-self: start;
  }

  .invoice-title-grid .eyebrow {
    grid-row: 1;
  }

  .invoice-title-grid h1 {
    grid-row: 2;
  }

  .invoice-sync-status {
    grid-row: 3;
  }

  .invoice-xml-cache-status {
    grid-row: 4;
  }

  .invoice-cache-card {
    grid-row: 5;
    width: 100%;
  }

  .invoice-sync-button {
    grid-row: 6;
  }

  .invoice-filter-form,
  .ops-filter-form,
  .period-form,
  .export-date-grid,
  .metrics,
  .columns,
  .client-metrics,
  .client-grid,
  .ksef-config-layout,
  .ops-metrics,
  .ops-grid,
  .form-grid,
  .rate-grid {
    grid-template-columns: 1fr;
  }

  .invoice-table {
    min-width: 1040px;
  }

  .page:has(.invoice-table-panel),
  .page:has(.daily-report-panel),
  .page:has(.replenishment-panel) {
    padding-bottom: 70px;
  }

  .invoice-pagination,
  .invoice-pagination-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-page-size-control {
    width: 100%;
  }

  .daily-report-heading,
  .daily-report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .daily-report-summary {
    grid-template-columns: 1fr;
  }

  .period-inline-form {
    grid-template-columns: 86px auto 58px auto;
    min-height: 62px;
    padding: 10px 12px;
  }

  .period-inline-form select,
  .period-inline-form span {
    font-size: 18px;
  }

  .vat-detail-grid {
    grid-template-columns: 1fr;
  }

  .replenishment-generator-form {
    grid-template-columns: 1fr;
  }

  .replenishment-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .replenishment-toolbar strong {
    margin-left: 0;
  }

  .mobile-nav {
    background: #ffffff;
    border-top: 1px solid var(--line);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    left: 0;
    position: fixed;
    right: 0;
    z-index: 20;
  }

  .mobile-nav a {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    padding: 13px 8px;
    text-align: center;
  }
}
