:root {
  --bg: #f5f7fc;
  --sidebar-bg: #f9fbff;
  --panel: #eef2f8;
  --panel-strong: #e6ecf6;
  --panel-soft: #ffffff;
  --text: #20283c;
  --muted: #79839a;
  --line: #d7dfec;
  --line-strong: #c4d0e4;
  --brand: #2f4bff;
  --brand-dark: #2439cf;
  --accent: #ff9f2f;
  --danger: #d73754;
  --ok: #18a26d;
  --warn: #c17a00;
  --shadow: 0 20px 45px rgba(23, 38, 74, 0.08);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 7% 64%, rgba(149, 117, 255, 0.16), transparent 20%),
    radial-gradient(circle at 12% 88%, rgba(71, 216, 251, 0.2), transparent 22%),
    radial-gradient(circle at 92% 12%, rgba(255, 159, 47, 0.14), transparent 18%),
    var(--bg);
}

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

a:hover {
  color: var(--brand-dark);
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  max-width: 100%;
}

.sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 250, 255, 0.94));
  border-right: 1px solid var(--line);
  padding: 1.65rem 1rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.3rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  padding: 0.35rem 0.45rem;
  border-radius: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand), #6f7dff);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(47, 75, 255, 0.28);
  flex: none;
}

.brand-copy {
  display: grid;
  gap: 0.06rem;
  min-width: 0;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.sidebar-nav {
  display: grid;
  gap: 0.3rem;
  align-content: start;
  padding-top: 0.5rem;
}

.sidebar-link {
  position: relative;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 11px;
  padding: 0.22rem 0.34rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover {
  background: #f2f6ff;
}

.sidebar-link-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  width: 100%;
  padding: 0.46rem 0.48rem;
  border-radius: 9px;
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: #5f6d89;
}

.sidebar-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-link.active {
  background: #edf2ff;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 0.42rem;
  bottom: 0.42rem;
  width: 4px;
  border-radius: 3px;
  background: var(--danger);
}

.sidebar-link.active .sidebar-icon {
  color: #3149db;
}

.sidebar-footer {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  min-height: 160px;
  overflow: hidden;
  padding: 0.9rem;
  display: grid;
  align-content: end;
}

.sidebar-version {
  color: var(--muted);
  font-size: 0.86rem;
  position: relative;
  z-index: 1;
}

.sidebar-orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.orb-a {
  width: 136px;
  height: 136px;
  left: -48px;
  bottom: -42px;
  border: 12px solid rgba(92, 213, 255, 0.7);
}

.orb-b {
  width: 52px;
  height: 52px;
  right: 28px;
  bottom: 28px;
  background: linear-gradient(145deg, rgba(126, 79, 255, 0.9), rgba(255, 90, 196, 0.75));
  transform: rotate(38deg);
}

.orb-c {
  width: 42px;
  height: 42px;
  left: 34px;
  top: 34px;
  background: linear-gradient(145deg, rgba(255, 155, 92, 0.75), rgba(255, 218, 126, 0.7));
  transform: rotate(22deg);
}

.admin-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  max-width: 100%;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 1.1rem 1.5rem;
  background: linear-gradient(180deg, rgba(245, 247, 252, 0.95), rgba(245, 247, 252, 0.5), rgba(245, 247, 252, 0));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.top-chip {
  border-radius: 10px;
  background: linear-gradient(145deg, #ffb04c, var(--accent));
  color: #fff;
  padding: 0.52rem 0.9rem;
  font-weight: 700;
  border: 1px solid rgba(255, 153, 44, 0.75);
  white-space: nowrap;
}

.top-chip:hover {
  color: #fff;
}

.user-avatar {
  width: 43px;
  height: 43px;
  border: 2px solid #2e3448;
  border-radius: 999px;
  color: #2e3448;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.top-logout {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.page-content {
  padding: 0 1.5rem 1.5rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.page-content > * {
  min-width: 0;
}

.public-shell {
  width: min(1100px, calc(100% - 1.4rem));
  margin: 1rem auto 2rem;
  max-width: 100%;
}

.public-topbar {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  padding: 0.8rem 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.public-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.public-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.34rem 0.7rem;
}

.public-link.active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.public-content {
  padding: 1rem 0 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.7rem;
  min-width: 0;
}

.page-head > div {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: clamp(1.7rem, 3.2vw, 3rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.42;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.panel,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  padding: 1rem;
  min-width: 0;
}

.panel-soft {
  background: var(--panel-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.35fr;
  gap: 0.85rem;
}

.insights-grid > * {
  min-width: 0;
}

.stat-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f2f5fb, #eaf0f8);
  padding: 0.82rem;
  display: grid;
  gap: 0.35rem;
}

.stat-label {
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: clamp(1.55rem, 2.4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.1;
}

.stat-note {
  font-size: 0.83rem;
  color: var(--muted);
}

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

.kpi-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.kpi-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(237, 243, 255, 0.65));
  padding: 0.7rem 0.75rem;
  display: grid;
  gap: 0.2rem;
}

.kpi-label {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.kpi-value {
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.1;
}

.kpi-note {
  color: var(--muted);
  font-size: 0.78rem;
}

.load-pill {
  border-radius: 999px;
  padding: 0.26rem 0.6rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.load-low {
  color: #1a7d56;
  background: #daf6ea;
}

.load-medium {
  color: #9b6500;
  background: #fff0cb;
}

.load-high {
  color: #99253b;
  background: #ffe2e8;
}

.progress-rail {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #d7e1f4;
  overflow: hidden;
}

.progress-rail > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f4bff, #6883ff);
}

.chart-card {
  display: grid;
  gap: 0.8rem;
}

.panel-head.compact {
  margin-bottom: 0;
}

.donut-layout {
  display: grid;
  grid-template-columns: 156px 1fr;
  align-items: center;
  gap: 0.85rem;
}

.donut-wrap {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto;
}

.donut-chart {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: conic-gradient(#18a26d 0% 35%, #c17a00 35% 60%, #2252c9 60% 80%, #93a2bd 80% 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 21px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid #dde5f2;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.donut-center-label {
  margin-top: 0.24rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.legend-list {
  display: grid;
  gap: 0.4rem;
}

.legend-row {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.58);
  padding: 0.4rem 0.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-dot.paid {
  background: #18a26d;
}

.legend-dot.pending {
  background: #c17a00;
}

.legend-dot.confirming {
  background: #2252c9;
}

.legend-dot.other {
  background: #93a2bd;
}

.legend-name {
  font-size: 0.86rem;
  color: var(--muted);
}

.legend-value {
  font-size: 0.9rem;
  font-weight: 700;
}

.line-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.line-summary-item {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
  padding: 0.4rem 0.58rem;
  display: grid;
  gap: 0.1rem;
  min-width: 88px;
}

.line-summary-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.line-summary-value {
  font-size: 1.1rem;
  font-weight: 800;
}

.line-chart-shell {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(237, 243, 255, 0.44));
  padding: 0.5rem 0.56rem 0.44rem;
}

.line-chart {
  width: 100%;
  height: 170px;
  display: block;
}

.line-grid line {
  stroke: #cfdaee;
  stroke-width: 1;
}

.line-area {
  fill: rgba(47, 75, 255, 0.1);
}

.line-path {
  fill: none;
  stroke: #2f4bff;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line-dots circle {
  fill: #ffffff;
  stroke: #2f4bff;
  stroke-width: 2;
}

.line-labels {
  margin-top: 0.15rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.panel-title {
  margin: 0;
  font-size: 1.1rem;
}

.panel-subtitle {
  margin: 0.24rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #f8fbff;
}

table {
  width: 100%;
  min-width: 730px;
  border-collapse: collapse;
}

thead th {
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  text-align: left;
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
}

td {
  font-size: 0.91rem;
  color: var(--text);
  padding: 0.68rem 0.7rem;
  border-bottom: 1px solid #dfe7f4;
  vertical-align: top;
}

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

tbody tr:hover td {
  background: #f1f6ff;
}

.table-link {
  font-weight: 700;
}

.empty-cell {
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.54rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.status-pending {
  color: var(--warn);
  background: #fff3d1;
}

.status-confirming,
.status-awaiting_confirmations {
  color: #2252c9;
  background: #deebff;
}

.status-paid,
.status-matched {
  color: #157a53;
  background: #d8f6e8;
}

.status-expired,
.status-cancelled,
.status-conflict,
.status-amount_mismatch,
.status-before_invoice,
.status-after_expired {
  color: #9a2036;
  background: #ffe1e7;
}

.status-seen,
.status-unmatched,
.status-already_linked {
  color: #4a5f85;
  background: #e7eef8;
}

form {
  display: grid;
  gap: 0.78rem;
}

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

.field {
  display: grid;
  gap: 0.28rem;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.field-note {
  color: var(--muted);
  font-size: 0.78rem;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.6rem 0.66rem;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #91a9ff;
  box-shadow: 0 0 0 3px rgba(47, 75, 255, 0.14);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.inline-form input {
  min-width: 0;
}

.action-stack {
  align-items: stretch;
}

.full-form {
  width: 100%;
  min-width: 0;
}

.full-form .btn {
  width: 100%;
}

.sticky-actions {
  position: static;
  padding-top: 0;
  background: transparent;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  padding: 0.48rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 20px rgba(47, 75, 255, 0.28);
}

.btn-outline {
  color: var(--text);
  border-color: var(--line-strong);
  background: #fff;
}

.btn-outline:hover {
  background: #f4f8ff;
}

.btn-danger {
  color: #fff;
  background: linear-gradient(145deg, #df3c59, #bc2e47);
}

.alert {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.72rem;
  font-size: 0.9rem;
}

.alert-error {
  color: #8f1e31;
  border-color: #f4bbca;
  background: #ffeef3;
}

.alert-success {
  color: #116946;
  border-color: #b3e8d2;
  background: #f0fff7;
}

.split-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.85rem;
}

.split-grid > * {
  min-width: 0;
}

.detail-list {
  display: grid;
  gap: 0.62rem;
}

.detail-item {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #f5f8ff;
  padding: 0.56rem 0.64rem;
  display: grid;
  gap: 0.22rem;
}

.detail-key {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.detail-value {
  font-size: 0.92rem;
  line-height: 1.36;
  overflow-wrap: anywhere;
}

.hint-box {
  margin-top: 0.85rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #f8fbff;
  padding: 0.62rem 0.68rem;
}

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

.hint-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.subline {
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.context-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.context-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #f6f9ff;
  color: #44506a;
  font-size: 0.73rem;
  padding: 0.22rem 0.48rem;
}

.log-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.56rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.log-info {
  color: #244bbd;
  background: #dfeaff;
}

.log-warn {
  color: #9b6500;
  background: #ffefca;
}

.log-danger {
  color: #96243b;
  background: #ffe3e9;
}

.log-muted {
  color: #4d5e7f;
  background: #eaf0f8;
}

.mono,
.code {
  font-family: "JetBrains Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.code {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #f8fbff;
  padding: 0.4rem 0.52rem;
  word-break: break-all;
}

.text-break {
  word-break: break-all;
}

.invoice-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 0.85rem;
}

.invoice-layout > * {
  min-width: 0;
}

.invoice-main,
.invoice-side {
  display: grid;
  gap: 0.72rem;
}

.invoice-amount-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #f5f8ff, #e8eefb);
  padding: 0.86rem;
  display: grid;
  gap: 0.5rem;
}

.invoice-amount {
  margin: 0;
  font-size: clamp(1.65rem, 5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.08;
}

.invoice-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.confirm-meter {
  height: 8px;
  border-radius: 999px;
  background: #d7e1f4;
  overflow: hidden;
}

.confirm-meter-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), #6380ff);
  transition: width 0.35s ease;
}

.invoice-meta {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #f8fbff;
  padding: 0.72rem;
  display: grid;
  gap: 0.55rem;
}

.invoice-meta-row {
  display: grid;
  gap: 0.18rem;
}

.invoice-meta-row .label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.invoice-meta-row .value {
  font-size: 0.92rem;
  font-weight: 600;
}

.invoice-steps {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.26rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.auth-wrap {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
}

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

@media (max-width: 1080px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-rows: auto auto;
  }

  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(140px, 1fr);
    overflow-x: auto;
    padding-top: 0;
  }

  .sidebar-link {
    text-align: center;
  }

  .sidebar-link-inner {
    justify-content: center;
  }

  .sidebar-link.active::before {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: -4px;
    width: auto;
    height: 3px;
  }

  .admin-topbar {
    padding: 0.85rem 1rem;
  }

  .page-content {
    padding: 0 1rem 1rem;
  }

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

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

  .split-grid,
  .invoice-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .public-shell {
    width: calc(100% - 0.85rem);
    margin-top: 0.5rem;
  }

  .public-topbar {
    padding: 0.72rem;
  }

  .public-nav {
    gap: 0.35rem;
  }

  .public-link {
    font-size: 0.83rem;
    padding: 0.3rem 0.58rem;
  }

  .admin-topbar-actions {
    gap: 0.4rem;
  }

  .top-chip {
    padding: 0.44rem 0.68rem;
    font-size: 0.84rem;
  }

  .user-avatar {
    width: 38px;
    height: 38px;
  }

  .top-logout {
    font-size: 0.84rem;
  }

  .page-title {
    font-size: clamp(1.45rem, 7.5vw, 2rem);
  }

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

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

  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .legend-list {
    width: 100%;
  }

  .line-summary {
    flex-wrap: wrap;
  }

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

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

  .inline-form input {
    min-width: 0;
  }

  .form-actions .btn,
  .sticky-actions .btn {
    width: 100%;
  }

  .sticky-actions {
    position: sticky;
    bottom: 0;
    padding-top: 0.5rem;
    background: linear-gradient(180deg, rgba(238, 242, 248, 0), rgba(238, 242, 248, 0.98) 32%);
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table {
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.55rem;
  }

  thead {
    display: none;
  }

  tbody tr {
    display: block;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #f4f8ff;
    overflow: hidden;
  }

  tbody tr:hover td {
    background: transparent;
  }

  td {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 0.4rem;
    padding: 0.5rem 0.66rem;
    border-bottom: 1px dashed var(--line-strong);
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
  }

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

  .empty-cell {
    display: block;
    border-bottom: 0;
    padding: 0.7rem;
  }

  .empty-cell::before {
    content: none;
  }

  .copy-row {
    display: grid;
  }

  .sidebar-nav {
    grid-auto-flow: row;
    grid-auto-columns: unset;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .sidebar-link {
    text-align: left;
  }

  .sidebar-link-inner {
    justify-content: flex-start;
  }
}

@media (max-width: 430px) {
  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 95px minmax(0, 1fr);
  }
}

@media (max-width: 360px) {
  .page-content {
    padding: 0 0.7rem 0.85rem;
  }

  .panel,
  .card {
    padding: 0.72rem;
  }

  .kpi-value,
  .stat-value {
    font-size: 1.05rem;
  }
}
