:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #5b665f;
  --line: #d9e1dc;
  --paper: #ffffff;
  --wash: #f4f7f5;
  --field: #fbfcfb;
  --brand: #116b5b;
  --brand-strong: #0a493e;
  --brand-soft: #e2f2ee;
  --danger: #a33f27;
  --shadow: 0 10px 32px rgba(24, 42, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--wash);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px 12px 96px;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -12px 14px;
  padding: 14px 12px 12px;
  background: rgba(244, 247, 245, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(217, 225, 220, 0.9);
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 20px;
}

.ghost-button,
.secondary-button {
  padding: 0 14px;
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button {
  background: var(--brand-soft);
  border-color: #bfded6;
  color: var(--brand-strong);
}

.quick-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mini-field,
.field,
.power-card,
.section,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.mini-field {
  min-width: 0;
  padding: 9px 10px;
}

.mini-field span,
.field span,
.field label,
.compact-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-field strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section {
  margin-bottom: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

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

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

.field {
  min-width: 0;
  padding: 9px 10px 10px;
  background: var(--field);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 750;
}

.field textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.35;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #9aa39d;
  font-weight: 650;
}

.field.is-focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(17, 107, 91, 0.12);
}

.field.is-required {
  border-color: #cbb58b;
  background: #fffaf0;
}

.field.is-readonly {
  background: #edf1ee;
}

.field.is-readonly input {
  color: var(--muted);
}

.item-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.item-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
}

.item-toggle input {
  width: 21px;
  height: 21px;
  accent-color: var(--brand);
}

.item-toggle:has(input:checked) {
  border-color: #bfded6;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.power-list {
  display: grid;
  gap: 10px;
}

.power-card {
  padding: 10px;
  background: var(--field);
}

.power-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.eye-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.power-title strong {
  flex: 1;
}

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

.power-input {
  min-width: 0;
}

.power-input label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.power-input input,
.power-input select {
  width: 100%;
  min-height: 46px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  outline: 0;
  padding: 9px;
}

.power-input select {
  appearance: auto;
}

.signed-power {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 6px;
}

.signed-power select:disabled {
  color: #9aa39d;
  background: #edf1ee;
}

.power-current {
  margin-top: 5px;
  min-height: 18px;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 900;
}

.contact-power-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #bfded6;
  border-radius: 8px;
  background: #f7fbf9;
}

.contact-power-panel[hidden] {
  display: none;
}

.contact-convert-row {
  margin-top: 10px;
}

.addition-card {
  background: #fff;
}

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

.same-add-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid #bfded6;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 850;
}

.same-add-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.same-add-row span {
  min-width: 0;
}

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

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

.mode-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.mode-button.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.split-payment {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfded6;
  border-radius: 8px;
  background: #f7fbf9;
}

.split-payment[hidden] {
  display: none;
}

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

.balance-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #bfded6;
  border-radius: 8px;
  background: var(--brand-soft);
}

.balance-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.balance-box strong {
  font-size: 28px;
  line-height: 1;
}

.save-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding: 10px 12px 14px;
  background: rgba(244, 247, 245, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.save-bar-inner {
  width: min(100%, 736px);
  margin: 0 auto;
}

.error-box {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #e3b4a5;
  border-radius: 8px;
  background: #fff1ec;
  color: var(--danger);
  font-weight: 750;
}

.login-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  align-items: center;
}

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

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.login-help {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-user {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.admin-user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-user-head strong,
.admin-user-head span {
  display: block;
}

.admin-user-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.permission-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.check-row,
.small-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.check-row {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-row input,
.small-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.pin-reset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.pin-reset-row input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  padding: 9px 10px;
}

.detail-hero {
  margin-bottom: 12px;
  padding: 16px;
  border-radius: 8px;
  background: var(--brand-strong);
  color: #fff;
}

.detail-hero h1 {
  margin-bottom: 6px;
}

.detail-hero p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.82);
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-panel {
  padding: 13px;
}

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

.fact {
  min-width: 0;
  padding: 9px;
  border-radius: 8px;
  background: var(--wash);
}

.fact span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.fact strong,
.fact p {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

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

.generated-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.generated-item strong {
  font-size: 15px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 900;
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
}

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

@media (min-width: 640px) {
  .app-shell {
    padding-top: 22px;
  }

  .top-bar {
    margin-top: -22px;
  }

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

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

  .field.wide,
  .section.wide {
    grid-column: 1 / -1;
  }

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

  .addition-card {
    grid-column: 1 / -1;
  }

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

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

  .detail-panel.wide {
    grid-column: 1 / -1;
  }
}
