:root {
  --ink: #0e1014;
  --sidebar: #141824;
  --sidebar-2: #1a2030;
  --panel: #ffffff;
  --canvas: #f3f5f9;
  --line: #e6eaf2;
  --muted: #6b7385;
  --text: #1a2030;
  --accent: #00a8d5;
  --accent-2: #0077a8;
  --accent-soft: rgba(0, 168, 213, 0.12);
  --ok: #1f9d6a;
  --warn: #c98512;
  --danger: #c23b3b;
  --orange: #e8793a;
  --gold: #d4a017;
  --violet: #4f6bed;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(20, 24, 36, 0.08);
  --font: "Public Sans", system-ui, sans-serif;
  --display: "Bricolage Grotesque", var(--font);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--canvas);
}

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

a {
  color: inherit;
}

body.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 10% 20%, rgba(0, 168, 213, 0.18), transparent 35%),
    radial-gradient(circle at 90% 80%, rgba(20, 24, 36, 0.18), transparent 40%),
    linear-gradient(160deg, #eef3f8, #f7f9fc 50%, #e8eef5);
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-card__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0e1014;
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

.login-card__logo img,
.login-card img {
  width: 140px;
  height: auto;
  display: block;
  margin: 0;
}

.login-card h1 {
  font-family: var(--display);
  font-size: 1.45rem;
  margin: 0 0 0.35rem;
}

.login-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #3d4556;
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea,
.search input,
.modal input,
.modal select,
.modal textarea,
.login-card input {
  width: 100%;
  border: 1px solid #d7deea;
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  background: #f7f9fc;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(20, 24, 36, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field input::placeholder,
.field textarea::placeholder,
.search input::placeholder,
.modal input::placeholder,
.login-card input::placeholder {
  color: #939bb0;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.search input:hover,
.modal input:hover,
.modal select:hover,
.modal textarea:hover,
.login-card input:hover {
  border-color: #b9c4d6;
  background: #fff;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search input:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus,
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field select,
.modal select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #6b7385 50%),
    linear-gradient(135deg, #6b7385 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.field textarea,
.modal textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.45;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn--ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 2;
}

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

.btn--sm {
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 10px;
}

.auth-status {
  min-height: 1.2rem;
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--danger);
}

.auth-status.is-ok {
  color: var(--ok);
}

.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), var(--ink));
  color: #d7dde8;
  padding: 1.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.sidebar__brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.sidebar__brand strong {
  display: block;
  color: #fff;
  font-family: var(--display);
  font-size: 1.05rem;
}

.sidebar__brand span {
  font-size: 0.75rem;
  color: #8b93a7;
}

.nav {
  display: grid;
  gap: 0.3rem;
  flex: 1;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  cursor: pointer;
}

.nav button svg {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  stroke-width: 2;
  opacity: 0.9;
}

.nav button.is-active,
.nav button:hover {
  background: rgba(0, 168, 213, 0.16);
  color: #fff;
}

.nav button.is-active {
  box-shadow: inset 0 0 0 1px rgba(0, 168, 213, 0.35);
}

.nav button.is-active svg,
.nav button:hover svg {
  opacity: 1;
  color: var(--accent);
}

.sidebar__user {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.85rem;
}

.sidebar__user strong {
  display: block;
  color: #fff;
  font-size: 0.9rem;
}

.sidebar__user span {
  font-size: 0.75rem;
  color: #8b93a7;
  word-break: break-all;
}

.sidebar__user .btn {
  margin-top: 0.7rem;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-backdrop {
  display: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted);
  pointer-events: none;
  stroke-width: 2;
}

.search input {
  padding-left: 2.55rem;
  background: #f7f9fc;
  min-height: 44px;
}

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

#alerts-btn {
  min-height: 44px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.content {
  padding: 1.25rem 1.5rem 2rem;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
}

.page-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.grid--dash {
  grid-template-columns: 1.6fr 1fr;
}

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

.card {
  background: var(--panel);
  border: 1px solid rgba(230, 234, 242, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
}

.card h2,
.card h3 {
  margin: 0 0 0.85rem;
  font-family: var(--display);
  font-size: 1.05rem;
}

.stat {
  display: grid;
  gap: 0.35rem;
}

.stat__label {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat__value {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
}

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

.stat--accent {
  background: linear-gradient(145deg, #e8f8fd, #ffffff);
}

.stat--warn {
  background: linear-gradient(145deg, #fff6e8, #ffffff);
}

.stat--ok {
  background: linear-gradient(145deg, #eafaf3, #ffffff);
}

.stat--danger {
  background: linear-gradient(145deg, #fdeeee, #ffffff);
}

.welcome {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  background: linear-gradient(120deg, #eaf7fc, #f5f0ff 60%, #fff);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
  border: 1px solid #e3eaf5;
}

.welcome h2 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
}

.welcome p {
  margin: 0;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 0.65rem;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem 0.9rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fbfcfe;
}

.list-item strong {
  display: block;
}

.list-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.pill--pending {
  background: #fff3d9;
  color: var(--warn);
}

.pill--paid,
.pill--registered,
.pill--sent,
.pill--active {
  background: #e5f8ef;
  color: var(--ok);
}

.pill--overdue,
.pill--danger {
  background: #fde8e8;
  color: var(--danger);
}

.pill--paused,
.pill--pending-status {
  background: #eef1ff;
  color: var(--violet);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 16, 20, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.modal h2 {
  margin: 0 0 1rem;
  font-family: var(--display);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 1rem;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  z-index: 60;
  box-shadow: var(--shadow);
}

.receipt-sheet {
  width: min(800px, 100%);
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid var(--line);
}

.receipt-sheet__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.receipt-sheet__head img {
  width: 150px;
  height: auto;
}

.bars {
  display: flex;
  align-items: end;
  gap: 0.55rem;
  height: 140px;
  padding-top: 0.5rem;
}

.bars span {
  flex: 1;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--accent), #123b5a);
  min-height: 8px;
}

.menu-toggle {
  display: none;
  min-height: 44px;
}

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

  .grid--dash,
  .grid--2 {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(14, 16, 20, 0.45);
    z-index: 35;
  }

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(288px, 88vw);
    max-width: 320px;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 40;
    height: 100dvh;
  }

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

  .menu-toggle {
    display: inline-flex;
  }

  .topbar {
    padding: 0.75rem 1rem;
    gap: 0.65rem;
  }

  .search {
    max-width: none;
  }

  .alerts-label {
    display: none;
  }

  .content {
    padding: 1rem;
  }

  .page-head {
    align-items: stretch;
  }

  .page-head .btn,
  .page-head .row-actions {
    width: 100%;
  }

  .page-head .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .welcome .btn {
    width: 100%;
  }

  .list-item {
    flex-direction: column;
    align-items: stretch;
  }

  .list-item .row-actions {
    width: 100%;
  }

  .list-item .row-actions .btn {
    flex: 1;
  }

  .table-wrap {
    margin: 0 -0.15rem;
  }

  table {
    min-width: 640px;
  }

  .modal {
    width: min(560px, 100%);
    padding: 1rem;
    border-radius: 16px;
  }

  .modal__actions {
    flex-direction: column-reverse;
  }

  .modal__actions .btn {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .grid--stats {
    grid-template-columns: 1fr;
  }

  .page-head h1 {
    font-size: 1.3rem;
  }

  .stat__value {
    font-size: 1.35rem;
  }

  .login-card {
    padding: 1.35rem;
    border-radius: 18px;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  #receipt-print,
  #receipt-print * {
    visibility: visible;
  }

  #receipt-print {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: 0;
    box-shadow: none;
  }
}
