:root {
  --bg: #f6f4ec;
  --card: #ffffff;
  --ink: #1d2b23;
  --muted: #6b7a6f;
  --line: #e6e2d4;
  --line-soft: #f0eee5;
  --brand: #0f6b4f;
  --brand-dark: #0a503a;
  --brand-soft: #e4f1ea;
  --gold: #b98a3e;
  --gold-soft: #f7eeda;
  --danger: #b23a32;
  --danger-soft: #fbeae8;
  --warn: #a96f17;
  --warn-soft: #fcf1dc;
  --blue: #2f5d8a;
  --blue-soft: #e8f0f8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 43, 32, 0.05), 0 10px 30px rgba(23, 43, 32, 0.05);
  --shell-1: #0b4a35;
  --shell-2: #083a2a;
  --shell-3: #062e21;
  --shell-4: #072f23;
  --brand-glow: rgba(15, 107, 79, 0.18);
}

/* ------------------------------ color palettes ------------------------------ */

:root[data-palette="royal"] {
  --brand: #1c5a99;
  --brand-dark: #123f6d;
  --brand-soft: #e7f0fa;
  --gold: #c08a2e;
  --gold-soft: #f8efd9;
  --blue: #2f5d8a;
  --blue-soft: #e8f0f8;
  --brand-glow: rgba(28, 90, 153, 0.2);
  --shell-1: #123f6b;
  --shell-2: #0e3357;
  --shell-3: #0a2742;
  --shell-4: #0b2c4b;
}

:root[data-palette="wine"] {
  --brand: #8c2f4a;
  --brand-dark: #6a2036;
  --brand-soft: #f8e9ee;
  --gold: #b98a3e;
  --gold-soft: #f7eeda;
  --blue: #6e4a60;
  --blue-soft: #f2eaf0;
  --brand-glow: rgba(140, 47, 74, 0.2);
  --shell-1: #5e1a30;
  --shell-2: #4e1528;
  --shell-3: #3d0f1f;
  --shell-4: #441327;
}

:root[data-palette="violet"] {
  --brand: #5a3fa0;
  --brand-dark: #432d7d;
  --brand-soft: #efeafb;
  --gold: #c39334;
  --gold-soft: #f9f0db;
  --blue: #5b6fb0;
  --blue-soft: #ebedf9;
  --brand-glow: rgba(90, 63, 160, 0.2);
  --shell-1: #3d2a6b;
  --shell-2: #322258;
  --shell-3: #271a45;
  --shell-4: #2b1d4d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", "Noto Naskh Arabic", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p {
  margin: 0;
}

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

button {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

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

.small {
  font-size: 12.5px;
}

.gold {
  color: var(--gold);
}

.danger {
  color: var(--danger);
}

.green {
  color: var(--brand);
}

.nowrap {
  white-space: nowrap;
}

.spacer {
  flex: 1;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.link {
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex: none;
}

/* ---------------------------- login ---------------------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(185, 138, 62, 0.16), transparent 45%),
    radial-gradient(circle at 85% 80%, var(--brand-glow), transparent 45%),
    linear-gradient(145deg, var(--shell-1) 0%, var(--shell-2) 55%, var(--shell-3) 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fffdf8;
  border-radius: 22px;
  padding: 38px 32px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.login-card .brand-badge {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  margin: 0 auto 16px;
  background: linear-gradient(140deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f0d9a8;
  box-shadow: inset 0 0 0 1px rgba(240, 217, 168, 0.35);
  overflow: hidden;
}

.login-card .brand-badge img,
.side-brand .mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.login-card h1 {
  font-size: 26px;
  letter-spacing: 0.5px;
}

.login-card > p {
  color: var(--muted);
  font-size: 13.5px;
  margin: 6px 0 26px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: right;
}

.login-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.login-hint {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* ---------------------------- layout ---------------------------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 252px;
  flex: none;
  background: linear-gradient(180deg, var(--shell-1) 0%, var(--shell-2) 70%, var(--shell-4) 100%);
  color: #e9f2ec;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
}

.side-brand .mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(240, 217, 168, 0.35);
  color: #f0d9a8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
}

.side-brand h1 {
  font-size: 19px;
  color: #fff;
}

.side-brand span {
  display: block;
  font-size: 11.5px;
  color: rgba(233, 242, 236, 0.6);
}

.side-nav {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  flex: 1;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(233, 242, 236, 0.78);
  font-size: 13.5px;
  font-weight: 600;
  transition: 0.15s;
  position: relative;
}

.side-nav a svg {
  width: 19px;
  height: 19px;
  opacity: 0.85;
  flex: none;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.side-nav a.active {
  background: rgba(240, 217, 168, 0.14);
  color: #f7e8c7;
}

.side-nav a.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: #d9b472;
}

.side-nav .nav-sep {
  margin: 10px 12px 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 11px;
  letter-spacing: 0.4px;
  color: rgba(233, 242, 236, 0.45);
}

.side-foot {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.side-user .avatar {
  background: rgba(240, 217, 168, 0.18);
  color: #f0d9a8;
}

.side-user b {
  display: block;
  font-size: 13px;
  color: #fff;
}

.side-user span {
  font-size: 11.5px;
  color: rgba(233, 242, 236, 0.55);
}

.logout-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(233, 242, 236, 0.8);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 12.5px;
  cursor: pointer;
}

.logout-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  background: rgba(246, 244, 236, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  font-size: 19px;
}

.topbar .sub {
  font-size: 12px;
  color: var(--muted);
}

.top-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.menu-btn {
  display: none;
}

.view {
  padding: 24px 26px 48px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* ---------------------------- cards & stats ---------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head h3 {
  font-size: 15px;
}

.card-head .spacer {
  flex: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

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

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.stat .ic {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.stat .ic svg {
  width: 21px;
  height: 21px;
}

.ic.green { background: var(--brand-soft); color: var(--brand); }
.ic.gold { background: var(--gold-soft); color: var(--gold); }
.ic.red { background: var(--danger-soft); color: var(--danger); }
.ic.blue { background: var(--blue-soft); color: var(--blue); }
.ic.warn { background: var(--warn-soft); color: var(--warn); }
.ic.gray { background: #f1f0ea; color: var(--muted); }

.stat .label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.stat .value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-top: 2px;
}

.stat .hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---------------------------- tables ---------------------------- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

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

.table th {
  background: #faf9f3;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-align: right;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background: #fbfaf6;
}

.table tfoot td {
  padding: 11px 12px;
  background: #faf9f3;
  font-weight: 700;
  border-top: 1px solid var(--line);
}

.table .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.table .row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .field {
  min-width: 135px;
}

.toolbar .spacer {
  flex: 1;
}

.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  padding-inline-start: 34px;
}

.section-title {
  font-size: 16px;
  margin: 26px 0 12px;
}

/* ---------------------------- buttons & forms ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}

.btn svg {
  width: 17px;
  height: 17px;
}

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

.btn-primary {
  background: var(--brand);
  color: #fff;
}

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

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

.btn-ghost:hover {
  background: #faf9f4;
}

.btn-gold {
  background: var(--gold);
  color: #fff;
}

.btn-gold:hover {
  background: #a3772f;
}

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

.btn-danger:hover {
  background: #982f28;
}

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

.btn-sm {
  height: 31px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
  gap: 5px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-block {
  width: 100%;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.icon-btn:hover {
  color: var(--ink);
  background: #faf9f4;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

.input,
select.input,
textarea.input {
  height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: 0.15s;
}

textarea.input {
  height: auto;
  min-height: 68px;
  padding: 10px 12px;
  resize: vertical;
}

.input:focus,
select.input:focus,
textarea.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 107, 79, 0.12);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7a6f' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
}

/* ---------------------------- badges ---------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.green { background: var(--brand-soft); color: var(--brand); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #f0efe8; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------------------------- chart ---------------------------- */

.chart {
  width: 100%;
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.chart-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-inline-end: 5px;
}

/* ---------------------------- modal & toast ---------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 28, 21, 0.48);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.18s ease-out;
}

.modal.wide {
  max-width: 920px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  font-size: 16px;
}

.modal-head .spacer {
  flex: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #fdfcf8;
  border-radius: 0 0 18px 18px;
}

.toast {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 24px;
  background: #17352a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: 0.2s;
  z-index: 200;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

/* ---------------------------- invoice builder ---------------------------- */

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

.items-table th {
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
  padding: 6px 5px;
  font-weight: 700;
}

.items-table td {
  padding: 5px;
  vertical-align: middle;
}

.items-table .input {
  height: 36px;
  font-size: 13px;
}

.items-table .line-total {
  font-weight: 700;
  white-space: nowrap;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

.remove-line {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.totals-box {
  background: #faf8f0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}

.totals-box .line {
  display: flex;
  justify-content: space-between;
}

.totals-box .grand {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  font-size: 17px;
  font-weight: 800;
}

/* ---------------------------- invoice print / detail ---------------------------- */

.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.doc-head h3 {
  font-size: 20px;
}

.doc-meta {
  text-align: left;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.8;
}

.doc-meta b {
  color: var(--ink);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

.detail-grid .box {
  background: #faf9f3;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 14px;
}

.detail-grid .box span {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 2px;
}

.detail-grid .box b {
  font-size: 13.5px;
}

/* ---------------------------- reports ---------------------------- */

.report-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.report-card h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

/* ---------------------------- misc ---------------------------- */

.login-screen .login-card form .btn {
  margin-top: 4px;
}

.credit {
  font-size: 11.5px;
  color: var(--muted);
}

.scrim {
  display: none;
}

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

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset-inline-start: -260px;
    transition: inset-inline-start 0.22s;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
  }
  .sidebar.open {
    inset-inline-start: 0;
  }
  .scrim.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 24, 18, 0.45);
    z-index: 35;
  }
  .menu-btn {
    display: inline-flex;
  }
  .topbar {
    padding: 12px 16px;
  }
  .view {
    padding: 16px 16px 40px;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat {
    padding: 13px;
    gap: 10px;
  }
  .stat .value {
    font-size: 17px;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .top-actions .pill {
    display: none;
  }
  .modal-backdrop {
    padding: 10px;
  }
}

.print-area {
  display: none;
}

@media print {
  body {
    background: #fff;
  }
  body > * {
    display: none !important;
  }
  .print-area {
    display: block !important;
    padding: 10px;
    color: #000;
    font-size: 12.5px;
  }
  .print-area h1 {
    font-size: 22px;
    margin-bottom: 4px;
  }
  .print-area .muted {
    color: #555;
  }
  .print-area .doc-head {
    border-color: #bbb;
  }
  .print-area table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
  }
  .print-area th,
  .print-area td {
    border: 1px solid #999;
    padding: 6px 8px;
    text-align: right;
    font-size: 12px;
  }
  .print-area th {
    background: #f1f1f1;
  }
  .print-area .print-totals {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
  .print-area .sign {
    margin-top: 44px;
    display: flex;
    justify-content: space-between;
  }
}

/* ------------------------------ dark theme ------------------------------ */

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101a15;
  --card: #16241d;
  --ink: #e8efe9;
  --muted: #97a89c;
  --line: #2a3b31;
  --line-soft: #213128;
  --brand: #3fbd8e;
  --brand-dark: #1d7a58;
  --brand-soft: #16372b;
  --gold: #ddb26c;
  --gold-soft: #332a18;
  --danger: #e57267;
  --danger-soft: #3a1f1c;
  --warn: #d9a24c;
  --warn-soft: #352a16;
  --blue: #7fa9d8;
  --blue-soft: #18293a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.3);
  --surface-2: #1b2a22;
  --surface-3: #22332a;
  --surface-4: #1a2a21;
  --surface-5: #14211b;
}

[data-theme="dark"][data-palette="royal"] {
  --bg: #0c1421;
  --card: #131f31;
  --ink: #e7eef8;
  --muted: #93a6bf;
  --line: #26374f;
  --line-soft: #1b2a3d;
  --brand: #69a9e8;
  --brand-dark: #2c5f9e;
  --brand-soft: #152943;
  --gold: #dcb36c;
  --gold-soft: #332a18;
  --danger: #e57368;
  --danger-soft: #3a1f1c;
  --warn: #d9a24c;
  --warn-soft: #352a16;
  --blue: #8ab4e4;
  --blue-soft: #18293a;
  --brand-glow: rgba(105, 169, 232, 0.18);
  --surface-2: #1a2a40;
  --surface-3: #21324b;
  --surface-4: #18273a;
  --surface-5: #111c2c;
}

[data-theme="dark"][data-palette="wine"] {
  --bg: #1a1014;
  --card: #25161c;
  --ink: #f4e9ec;
  --muted: #b2959e;
  --line: #3d2730;
  --line-soft: #2e1e25;
  --brand: #e58aa3;
  --brand-dark: #a83f5c;
  --brand-soft: #3a1f28;
  --gold: #ddb26c;
  --gold-soft: #332a18;
  --danger: #e57368;
  --danger-soft: #3a1f1c;
  --warn: #d9a24c;
  --warn-soft: #352a16;
  --blue: #c39aa9;
  --blue-soft: #332530;
  --brand-glow: rgba(229, 138, 163, 0.16);
  --surface-2: #2c1c23;
  --surface-3: #38242d;
  --surface-4: #2a1b21;
  --surface-5: #211419;
}

[data-theme="dark"][data-palette="violet"] {
  --bg: #141020;
  --card: #1d1730;
  --ink: #ece8f8;
  --muted: #a79ec0;
  --line: #342a4e;
  --line-soft: #261f3a;
  --brand: #a993ec;
  --brand-dark: #6c50b5;
  --brand-soft: #2a2145;
  --gold: #e0b56c;
  --gold-soft: #332a18;
  --danger: #e57368;
  --danger-soft: #3a1f1c;
  --warn: #d9a24c;
  --warn-soft: #352a16;
  --blue: #9aa8e2;
  --blue-soft: #232844;
  --brand-glow: rgba(169, 147, 236, 0.16);
  --surface-2: #251f3a;
  --surface-3: #2e2747;
  --surface-4: #231d36;
  --surface-5: #1a1528;
}

[data-theme="dark"] .topbar {
  background: rgba(16, 26, 21, 0.88);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}

[data-theme="dark"] .login-card {
  background: var(--card);
}

[data-theme="dark"] .login-hint {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

[data-theme="dark"] .btn {
  background: var(--surface-2);
}

[data-theme="dark"] .btn-ghost {
  background: transparent;
  border-color: var(--line);
}

[data-theme="dark"] .btn-ghost:hover {
  background: var(--surface-3);
}

[data-theme="dark"] .input,
[data-theme="dark"] textarea.input {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme="dark"] .input::placeholder {
  color: #7d8f83;
}

[data-theme="dark"] .table th {
  background: var(--surface-4);
}

[data-theme="dark"] .table tbody tr:hover {
  background: var(--surface-2);
}

[data-theme="dark"] .table tfoot td {
  background: var(--surface-4);
}

[data-theme="dark"] .icon-btn {
  background: var(--surface-2);
}

[data-theme="dark"] .icon-btn:hover {
  background: var(--surface-3);
}

[data-theme="dark"] .theme-btn {
  color: var(--gold);
}

[data-theme="dark"] .pill {
  background: var(--surface-2);
}

[data-theme="dark"] .modal {
  background: var(--card);
}

[data-theme="dark"] .modal-foot {
  background: var(--surface-5);
}

[data-theme="dark"] .totals-box {
  background: var(--surface-4);
}

[data-theme="dark"] .detail-grid .box {
  background: var(--surface-2);
}

[data-theme="dark"] .report-card {
  background: var(--card);
}

[data-theme="dark"] .remove-line {
  background: var(--surface-2);
}

[data-theme="dark"] .badge.gray {
  background: var(--surface-3);
}

[data-theme="dark"] .ic.gray {
  background: var(--surface-3);
}

[data-theme="dark"] .toast {
  background: var(--surface-3);
}

[data-theme="dark"] .empty {
  color: var(--muted);
}

/* ------------------------------ icon polish ------------------------------ */

.side-nav a svg {
  width: 30px;
  height: 30px;
  padding: 5.5px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
  transition: 0.15s;
}

.side-nav a:hover svg {
  background: rgba(255, 255, 255, 0.12);
}

.side-nav a.active svg {
  background: rgba(240, 217, 168, 0.16);
  color: #f7e8c7;
}

.theme-btn {
  color: var(--gold);
}

.rep-nav button svg {
  width: 22px;
  height: 22px;
}

.rep-nav button.active svg {
  transform: translateY(-1px);
}

.login-notice {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-line;
  border: 1px solid rgba(176, 58, 58, 0.25);
}

.danger-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.7;
}

.danger-note svg {
  flex: 0 0 auto;
  margin-top: 3px;
}

.code-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed var(--brand);
  background: var(--brand-soft, rgba(15, 107, 79, 0.06));
}

.code-box span {
  font-size: 12px;
  color: var(--muted);
}

.code-box b {
  font-size: 26px;
  letter-spacing: 6px;
  color: var(--brand);
  direction: ltr;
  text-align: center;
}

.code-box small {
  font-size: 11.5px;
  color: var(--muted);
}

.code-text {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 2px;
  direction: ltr;
  display: inline-block;
  color: var(--brand);
}

.code-input {
  text-align: center;
  font-size: 22px;
  letter-spacing: 8px;
  direction: ltr;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.login-switch {
  display: block;
  margin: 10px auto 0;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
}

/* ------------------------------ palette picker ------------------------------ */

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

.palette-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: right;
  cursor: pointer;
  transition: 0.15s;
}

.palette-card:hover {
  border-color: var(--brand);
}

.palette-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.palette-swatch {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.palette-card b {
  display: block;
  font-size: 13.5px;
}

.palette-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.palette-check {
  margin-inline-start: auto;
  color: var(--brand);
  display: none;
}

.palette-card.active .palette-check {
  display: inline-flex;
}
