:root {
  --primary: #8a1c2e;
  --primary-dark: #6b1522;
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #1c1c28;
  --muted: #6b6b7b;
  --border: #e3e3ef;
  --danger: #d6455a;
  --success: #21a179;
  --warn: #d68a21;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-header .brand {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.app-header .brand small { color: var(--muted); font-weight: 500; font-size: 12px; }
.app-header .brand-logo { height: 28px; width: auto; display: block; }

.app-header .menu-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}
.drawer.open { display: block; }
.drawer .backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
}
.drawer .panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 82%; max-width: 320px;
  background: var(--card);
  padding: 16px;
  overflow-y: auto;
}
.drawer nav a, .drawer nav button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 10px;
  border-radius: 10px;
  color: var(--text);
  border: none;
  background: none;
  font-size: 15px;
  cursor: pointer;
}
.drawer nav a:active, .drawer nav button:active { background: var(--bg); }
.drawer .section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 16px 10px 4px;
}

main {
  padding: 14px;
  max-width: 760px;
  margin: 0 auto;
  padding-bottom: 90px;
}

h1 { font-size: 20px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.grid-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.grid-links a {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
.field textarea { min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.checkbox-row input { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  width: 100%;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}
.alert.error { background: #fdeaec; color: var(--danger); }
.alert.success { background: #e6f6f0; color: var(--success); }
.alert.warn { background: #fdf3e3; color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.gray { background: #eee; color: #555; }
.badge.green { background: #e6f6f0; color: var(--success); }
.badge.red { background: #fdeaec; color: var(--danger); }
.badge.orange { background: #fdf3e3; color: var(--warn); }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 12px; color: var(--muted); }

.step-indicator {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.step-indicator div {
  flex: 1;
  height: 5px;
  border-radius: 4px;
  background: var(--border);
}
.step-indicator div.active { background: var(--primary); }
.step-indicator div.done { background: var(--success); }

.wizard-step { display: none; }
.wizard-step.active { display: block; }

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.cart-item .name { font-weight: 600; font-size: 14px; }
.cart-item .qty-controls { display: flex; align-items: center; gap: 8px; }
.cart-item .qty-controls button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 16px; cursor: pointer;
}

.total-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.total-line.grand { font-weight: 700; font-size: 18px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }

#signature-pad-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; touch-action: none; background: #fff; }
#signature-pad { width: 100%; height: 180px; display: block; touch-action: none; }

.offline-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--warn); color: #fff; text-align: center;
  padding: 8px; font-size: 13px; z-index: 40; display: none;
}
.offline-banner.show { display: block; }

.sync-badge {
  position: fixed; bottom: 14px; right: 14px; z-index: 35;
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 30px;
  font-size: 13px; display: none; box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.sync-badge.show { display: block; }

.legend-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

@media (min-width: 640px) {
  main { padding: 24px; }
  .grid-links { grid-template-columns: repeat(3, 1fr); }
}
