:root {
  color: #172033;
  background: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ecfeff 0, rgba(248, 250, 252, 0) 220px),
    #f8fafc;
}

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

input,
textarea,
select {
  font-size: 16px;
}

button {
  touch-action: manipulation;
}

.app {
  width: 100%;
  max-width: 640px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(env(safe-area-inset-bottom) + 88px);
}

.topbar {
  position: static;
  z-index: 20;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px;
  border-bottom: 1px solid #dbe5e9;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(14px);
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.titleblock {
  min-width: 0;
}

.app-title {
  margin: 0;
  overflow: hidden;
  color: #0f172a;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle {
  margin: 2px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border-radius: 10px;
  background: #eef2f7;
}

.sync-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.sync-strip span,
.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 4px 7px;
  line-height: 1.1;
}

.sync-strip.synced span,
.sync-badge.synced {
  background: #dcfce7;
  color: #166534;
}

.sync-strip.pending span,
.sync-badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.sync-strip.failed span,
.sync-badge.failed {
  background: #ffe4e6;
  color: #be123c;
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.tab.active {
  background: #fff;
  color: #0f766e;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.main {
  padding: 16px;
}

.stack {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid #dbe5e9;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.panel.primary {
  border-color: #99f6e4;
}

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

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

.mode-label {
  color: #334155;
  font-size: 14px;
  font-weight: 900;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.input {
  min-height: 48px;
  padding: 11px 12px;
}

.textarea {
  min-height: 88px;
  padding: 11px 12px;
  resize: vertical;
}

.textarea.small {
  min-height: 76px;
}

.input:focus,
.textarea:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

.extension-field {
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  padding: 10px;
}

.extension-field .field-label {
  color: #0f766e;
}

.extension-field .input {
  border-color: #14b8a6;
  background: #fff;
}

.input + .textarea {
  margin-top: 8px;
}

.preview {
  min-height: 20px;
  margin-top: 4px;
  color: #0f766e;
  font-size: 14px;
  font-weight: 900;
}

.preview.negative,
.total-amount.negative,
.summary-amount.negative {
  color: #be123c;
}

.preview:empty {
  min-height: 0;
}

.today-total {
  display: grid;
  gap: 4px;
}

.total-amount {
  color: #0f766e;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.1;
}

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

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

.phone-row,
.amount-row {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 8px;
  align-items: stretch;
}

.hyphen-btn,
.minus-btn {
  min-height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 22px;
  font-weight: 900;
}

.minus-btn {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

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

.seg-btn {
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 900;
}

.seg-btn.active {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}

.seg[data-segment="orderType"] .seg-btn {
  border-width: 2px;
}

.seg[data-segment="orderType"] .seg-btn.active {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}

.seg[data-segment="orderType"] .seg-btn:not(.active) {
  background: #fff;
  color: #334155;
}

.big-btn,
.small-btn {
  border-radius: 8px;
  font-weight: 900;
}

.big-btn {
  min-height: 52px;
  border: 1px solid transparent;
  padding: 12px 16px;
  font-size: 16px;
}

.small-btn {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  padding: 9px 10px;
  font-size: 14px;
}

.small-btn.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.btn-main {
  background: #0f766e;
  color: #fff;
}

.btn-dark {
  background: #172033;
  color: #fff;
}

.btn-plain {
  border-color: #cbd5e1;
  background: #fff;
  color: #1e293b;
}

.btn-danger {
  border-color: #fecaca;
  background: #fff;
  color: #be123c;
}

.actions {
  display: grid;
  gap: 8px;
}

.primary-action {
  min-height: 60px;
  font-size: 18px;
}

.save-sub-action {
  justify-self: center;
  min-width: 148px;
  background: transparent;
  color: #64748b;
}

.order-card {
  border: 1px solid #dbe5e9;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.order-summary {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.summary-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.summary-main {
  min-width: 0;
}

.summary-title,
.summary-category,
.summary-property,
.summary-customer {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-title {
  color: #0f172a;
  font-size: 16px;
  font-weight: 900;
}

.summary-category {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  padding: 3px 7px;
}

.sync-badge {
  width: fit-content;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 900;
}

.summary-property {
  margin-top: 3px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.summary-customer {
  margin-top: 2px;
  color: #64748b;
  font-size: 14px;
}

.summary-amount {
  flex: 0 0 auto;
  color: #0f766e;
  font-size: 16px;
  font-weight: 900;
}

.detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 5px 8px;
  font-size: 14px;
}

.detail-grid dt {
  color: #64748b;
  font-weight: 800;
}

.detail-grid dd {
  margin: 0;
  color: #0f172a;
  white-space: pre-wrap;
}

.note {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.settings-history {
  display: grid;
  gap: 8px;
}

.settings-history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
}

.settings-history-main {
  min-width: 0;
}

.settings-history-title,
.settings-history-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-history-title {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
}

.settings-history-sub {
  margin-top: 2px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.clone-title {
  margin: 12px 0 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.empty {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 28px 16px;
  color: #64748b;
  text-align: center;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  left: 16px;
  z-index: 40;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  padding: 13px 16px;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
}

.hidden {
  display: none;
}

@media (max-width: 380px) {
  .main {
    padding: 12px;
  }

  .topbar {
    padding-right: 12px;
    padding-left: 12px;
  }

  .seg-btn,
  .small-btn {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 13px;
  }
}
