:root {
  color-scheme: light;
  --ink: #142033;
  --muted: #5c6b80;
  --line: #d7dfeb;
  --paper: #f4f7fb;
  --card: #ffffff;
  --navy: #17325c;
  --gold: #c4a15a;
  --danger: #8d2d2d;
  --ok: #1f6b45;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--navy);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  color: white;
  text-decoration: none;
}

.brand img {
  height: 46px;
  width: auto;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  padding: 4px 6px;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 20px 64px; }
.wrap:has(.admin-shell) { max-width: 1180px; }

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

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.split { grid-template-columns: minmax(240px, 320px) 1fr; align-items: start; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.8rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }

form { display: grid; gap: 12px; margin-top: 12px; }
label { display: grid; gap: 6px; font-size: 0.92rem; font-weight: 600; }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}
textarea { min-height: 80px; resize: vertical; }

button, .ghost {
  font: inherit;
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--navy);
  color: white;
  cursor: pointer;
}
button.secondary, .ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.top .ghost { color: white; border-color: rgba(255, 255, 255, 0.35); }
button.danger { background: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.alert {
  background: #fdecec;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
}
.note {
  background: #f3f7f4;
  color: var(--ok);
  border-radius: 10px;
  padding: 10px 12px;
}
.qr {
  width: min(220px, 70vw);
  height: auto;
  background: white;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.secret, .codes {
  font-family: ui-monospace, monospace;
  word-break: break-all;
  background: #f7f4ea;
  border-radius: 10px;
  padding: 12px;
}
.codes { display: grid; gap: 4px; }

.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list button, .row {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  background: white;
}
.row { border: 1px solid var(--line); padding: 10px 12px; }
.status {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef3f9;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
fieldset label { font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.invoice-dates { display: grid; gap: 6px; margin: 12px 0; }
.invoice-dates p { margin: 0; }
.invoice-preview { width: 100%; }
.invoice-preview th, .invoice-preview td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.invoice-preview td:last-child, .invoice-preview th:last-child { text-align: right; white-space: nowrap; }
details.adjust { margin-top: 16px; }
details.adjust summary { cursor: pointer; font-weight: 600; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.section { margin-top: 22px; }

.profile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.profile-head h2 { margin-bottom: 4px; }
.profile-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}
.profile-tabs button { flex: 1 1 150px; width: auto; white-space: normal; text-align: left; }
.profile-tabs button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #1a7fd4;
  outline-offset: 2px;
}
.tab-panel { margin-top: 8px; }
.fields { margin: 0; }
.field-grid { display: grid; gap: 12px; }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; }
.unsaved {
  background: #fbf6ea;
  color: #6b5420;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
}
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }

.admin-shell {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.admin-main { min-width: 0; }
.admin-nav {
  display: grid;
  gap: 4px;
  position: sticky;
  top: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}
.nav-toggle { display: none; width: auto; }
.nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
}
.nav-link.selected {
  background: var(--navy);
  color: white;
}
.page-head h1 { margin-bottom: 4px; }
.page-head p, .toolbar { margin: 0; }
.toolbar a { color: var(--navy); font-weight: 600; }
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.shortcut {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  background: #f7faff;
}
.customer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.customer-row p { margin: 0; }
.customer-row .customer-name {
  width: auto;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--navy);
  font-weight: 700;
  text-align: left;
}
.customer-row .open-customer {
  width: auto;
  flex: 0 0 auto;
  background: var(--navy);
  color: white;
}
.package-card button { width: auto; }
.profile-view { width: 100%; }
.package-meta { margin: 0; }
.price-form {
  margin-top: 8px;
  padding: 12px;
  border-radius: 10px;
  background: #f4f7fb;
}
.package-create { max-width: 760px; }
.platform-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px 12px;
}
.platform-options label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.platform-options input { width: auto; }
.alert.compact, .note.compact { padding: 6px 10px; margin: 0 0 8px; }
h4 { margin: 0 0 8px; font-size: 1rem; }

@media (min-width: 720px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  .invoice-preview { display: block; overflow-x: auto; }
  .split { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; align-items: center; }
  .admin-nav { display: none; position: static; }
  .admin-nav.open { display: grid; }
  .profile-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .profile-tabs button { width: 100%; }
  .top { padding: 14px 16px; }
  .wrap { padding: 16px 12px 48px; }
  h1 { font-size: 1.45rem; }
}
