:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #687287;
  --line: #dde3ee;
  --brand: #116a67;
  --brand-dark: #0d4f4d;
  --accent: #d98f2b;
  --danger: #c94545;
  --warning: #d99419;
  --positive: #16875f;
  --shadow: 0 18px 45px rgba(24, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f7;
}

.auth-screen[hidden],
.app-shell[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 150px;
  height: auto;
}

.auth-card h1 {
  margin: 2px 0 0;
  font-size: 1.8rem;
  letter-spacing: 0;
}

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

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

.auth-form input:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(17, 106, 103, 0.15);
}

.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #102023;
  color: #f7fbfb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand-logo {
  width: 84px;
  height: auto;
  border-radius: 4px;
  background: #ffffff;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #a9bdc0;
  font-size: 0.84rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: #dce8e9;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #1e383c;
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #7ed3ca;
  font-size: 1.05rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-footer span,
.sidebar-footer strong {
  display: block;
}

.sidebar-footer span {
  color: #a9bdc0;
  font-size: 0.82rem;
}

.sidebar-footer strong {
  margin-top: 4px;
  font-size: 0.95rem;
}

.sidebar-logout {
  width: 100%;
  margin-top: 12px;
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 28px;
}

.year-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(24, 32, 51, 0.06);
}

.year-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.year-selector label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.year-selector select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #f7f9fc;
  color: var(--text);
  font-weight: 800;
}

.year-bar-actions {
  display: flex;
  justify-content: flex-end;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.primary-button {
  padding: 0 16px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

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

.ghost-button {
  padding: 0 14px;
  background: #f7f9fc;
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  display: none;
  width: 42px;
  background: #ffffff;
  border-color: var(--line);
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
}

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

.metric-card,
.panel,
.placeholder-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-card strong {
  font-size: 1.75rem;
  letter-spacing: 0;
}

.metric-trend {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.positive {
  color: var(--positive);
  background: #e8f6ef;
}

.warning {
  color: var(--warning);
  background: #fff4df;
}

.danger {
  color: var(--danger);
  background: #fdeaea;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.75fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2,
.placeholder-section h2 {
  margin: 3px 0 0;
  font-size: 1.12rem;
  letter-spacing: 0;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(34px, 1fr));
  align-items: end;
  gap: 14px;
  height: 260px;
  padding-top: 8px;
}

.bar {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 100%;
}

.bar::before {
  content: "";
  width: 100%;
  height: var(--height);
  min-height: 28px;
  border-radius: 8px 8px 4px 4px;
  background: #c7d7d5;
}

.bar.active::before {
  background: var(--brand);
}

.bar span {
  position: absolute;
  bottom: -24px;
  color: var(--muted);
  font-size: 0.82rem;
}

.task-list {
  display: grid;
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.task-list li {
  display: grid;
  grid-template-columns: 12px auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.task-list li:last-child {
  border-bottom: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.table-panel {
  margin-top: 16px;
}

.numbering-panel {
  margin-top: 16px;
}

.danger-zone-panel {
  margin-top: 16px;
}

.numbering-grid {
  display: grid;
  grid-template-columns: minmax(210px, 0.75fr) minmax(260px, 1fr) minmax(230px, 0.8fr);
  gap: 16px;
  align-items: stretch;
}

.number-preview,
.rule-list,
.year-lock {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.number-preview {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
}

.number-preview span,
.rule-label,
.year-lock p {
  color: var(--muted);
  font-size: 0.86rem;
}

.number-preview strong {
  font-size: 2rem;
  letter-spacing: 0;
}

.rule-list {
  display: grid;
  gap: 0;
}

.rule-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.rule-list div:last-child {
  border-bottom: 0;
}

.year-lock {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 16px;
}

.year-lock p {
  margin: 0;
  line-height: 1.45;
}

.danger-button {
  min-height: 42px;
  border: 1px solid #f2c7c7;
  border-radius: 8px;
  background: #fdeaea;
  color: var(--danger);
  font-weight: 800;
}

.danger-button:hover {
  background: #fadada;
}

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

.danger-action {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #f2c7c7;
  border-radius: 8px;
  background: #fff7f7;
}

.danger-action-strong {
  background: #fff1f1;
}

.danger-action h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.danger-action p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.danger-action label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.danger-action input,
.danger-action textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text);
  resize: vertical;
}

.danger-action input:focus,
.danger-action textarea:focus {
  border-color: var(--danger);
  outline: 2px solid rgba(201, 69, 69, 0.15);
}

.action-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 700;
}

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

.action-message.success {
  color: var(--positive);
}

.segmented-control {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.segmented-control button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented-control button.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(24, 32, 51, 0.08);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.open {
  color: #145c89;
  background: #e6f2fb;
}

.pill.late {
  color: var(--danger);
  background: #fdeaea;
}

.pill.paid {
  color: var(--positive);
  background: #e8f6ef;
}

.placeholder-section {
  padding: 28px;
}

.workspace-section {
  display: none;
}

.workspace-section.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 3px 0 0;
  font-size: 1.4rem;
  letter-spacing: 0;
}

.invoice-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.invoice-next-number {
  color: var(--brand);
  font-size: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label,
.note-field,
.field-hint {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.field-hint {
  display: block;
  font-weight: 600;
  line-height: 1.35;
}

.form-grid input,
.form-grid select,
.note-field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

.form-grid input:focus,
.form-grid select:focus,
.note-field textarea:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(17, 106, 103, 0.15);
}

.line-items-block {
  margin-top: 18px;
}

.compact-header {
  margin-bottom: 10px;
}

.line-items-table td,
.line-items-table th {
  white-space: normal;
}

.line-items-table input,
.line-items-table select {
  width: 100%;
  min-width: 72px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 8px;
  background: #f7f9fc;
  color: var(--text);
}

.line-items-table input:focus,
.line-items-table select:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(17, 106, 103, 0.15);
  background: #ffffff;
}

.line-items-table select {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.line-items-table .line-description {
  min-width: 220px;
}

.line-currency,
.line-total-eur {
  font-weight: 700;
}

.note-field {
  margin-top: 16px;
}

.invoice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.validation-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f7f9fc;
}

.validation-card h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.validation-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.note-template-panel {
  margin-top: 18px;
}

.note-template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.note-template-card {
  display: grid;
  gap: 10px;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f7f9fc;
}

.note-template-card strong,
.note-template-card span {
  display: block;
}

.note-template-card p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.muted-template {
  background: #ffffff;
}

.muted-template p,
.muted-template strong {
  color: var(--muted);
}

.invoice-preview-panel {
  align-self: start;
}

.invoice-paper {
  min-height: 700px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  color: #111111;
}

.paper-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.paper-logo {
  width: 150px;
  height: auto;
  object-fit: contain;
}

.paper-top strong,
.paper-top span,
.paper-title-block strong,
.paper-client span,
.paper-client strong,
.paper-meta-grid span,
.paper-meta-grid strong,
.paper-total span,
.paper-total strong,
.paper-note span,
.paper-payment span,
.paper-payment strong,
.paper-signature span,
.paper-signature strong {
  display: block;
}

.paper-top span,
.paper-client span,
.paper-meta-grid span,
.paper-total span,
.paper-note span,
.paper-payment span,
.paper-signature span {
  color: var(--muted);
  font-size: 0.82rem;
}

.paper-title-block,
.paper-meta-grid,
.paper-client,
.paper-items-table,
.paper-total,
.paper-note,
.paper-payment,
.paper-signature {
  margin-top: 22px;
}

.paper-title-block {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.paper-title-block h3 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.08em;
}

.paper-title-block strong {
  color: var(--brand);
  font-size: 1.25rem;
}

.paper-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

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

.paper-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.paper-items-table th,
.paper-items-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  white-space: normal;
}

.paper-items-table th {
  color: #111111;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.paper-items-table th:not(:first-child),
.paper-items-table td:not(:first-child) {
  text-align: right;
}

.paper-total {
  display: grid;
  gap: 10px;
}

.paper-total div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.paper-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.paper-note p {
  margin: 6px 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.paper-payment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.paper-signature {
  display: grid;
  justify-items: end;
  gap: 4px;
  padding-top: 12px;
}

.paper-footer {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.master-data-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.batch-panel {
  align-self: start;
}

.editor-panel {
  align-self: start;
}

.stacked-form {
  display: grid;
  gap: 12px;
}

.stacked-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.stacked-form input,
.stacked-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

.stacked-form input:focus,
.stacked-form select:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(17, 106, 103, 0.15);
}

.export-rule-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.export-rule-card strong {
  color: var(--text);
  font-size: 0.9rem;
}

.export-rule-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.export-rule-card code {
  color: var(--text);
  font-size: 0.82rem;
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px !important;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.assignment-preview {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.assignment-preview span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.assignment-preview strong {
  color: var(--text);
  font-size: 0.92rem;
}

.assignment-preview p {
  margin: 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.subpanel-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.batch-actions {
  display: grid;
  gap: 10px;
}

.csv-template-card {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.csv-template-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.csv-template-card code {
  display: block;
  overflow-x: auto;
  padding: 8px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 0.78rem;
  white-space: nowrap;
}

.csv-template-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.logo-asset-preview {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.logo-asset-preview img {
  max-width: 180px;
  height: auto;
}

.logo-asset-preview span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kpr-panel {
  background: #eef2f7;
}

.kpr-sheet {
  max-width: 1120px;
  margin: 0 auto;
  border: 1px solid #b8c0cc;
  border-radius: 4px;
  padding: 22px;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 10px 26px rgba(24, 32, 51, 0.1);
}

.kpr-title-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 36px;
  text-align: center;
}

.kpr-title-row h3 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.kpr-year {
  margin: 0 0 10px;
}

.kpr-form-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 0.78rem;
}

.kpr-form-table th,
.kpr-form-table td {
  border: 1px solid #000000;
  padding: 6px;
  color: #000000;
  white-space: normal;
  vertical-align: middle;
}

.kpr-form-table th {
  text-align: center;
  text-transform: none;
}

.kpr-section-title {
  background: #f3f4f6;
  font-weight: 800;
}

.kpr-fill {
  color: #0066cc;
}

.kpr-scroll {
  margin-top: 0;
}

.kpr-traffic-table th {
  font-size: 0.72rem;
  line-height: 1.2;
}

.kpr-column-numbers th {
  font-weight: 700;
}

.kpr-total-label {
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 32, 35, 0.52);
}

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

.modal {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(24, 32, 51, 0.26);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 3px 0 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.modal-close {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 1.3rem;
}

.payment-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.payment-summary span {
  color: var(--muted);
  font-size: 0.86rem;
}

.payment-summary strong {
  color: var(--brand);
}

.warning-box {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #f0d09b;
  border-radius: 8px;
  background: #fff7e8;
}

.warning-box strong {
  color: #9b640d;
}

.warning-box p {
  margin: 0;
  color: var(--text);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.placeholder-section p {
  max-width: 720px;
  color: var(--muted);
}

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

@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .numbering-grid {
    grid-template-columns: 1fr;
  }

  .danger-grid {
    grid-template-columns: 1fr;
  }

  .invoice-workspace,
  .master-data-grid {
    grid-template-columns: 1fr;
  }

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

  .note-template-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(82vw, 300px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .year-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .year-bar-actions,
  .year-bar-actions .ghost-button {
    width: 100%;
  }

  .icon-button {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .search,
  .primary-button {
    flex: 1 1 210px;
  }
}

@media (max-width: 620px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .kpr-sheet {
    padding: 12px;
  }

  .kpr-title-row {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 20px;
  }

  .modal-actions {
    display: grid;
  }
}
