/* ===== Mobile-first styles ===== */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --primary: #1e4fa3;
  --primary-dark: #143a7a;
  --accent1: #1e4fa3;
  --accent2: #2e7d32;
  --accent3: #ef6c00;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --shadow: 0 6px 18px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Sarabun", "Tahoma", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 18px 16px 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.app-header p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.container {
  flex: 1;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* Rich menu grid */
.rich-menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 8px;
}

.menu-btn {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: 22px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  width: 100%;
  font-family: inherit;
}

.menu-btn:active {
  transform: scale(0.98);
}

.menu-btn .icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  color: #fff;
}

.menu-btn .label {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.menu-btn .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.menu-btn.track .icon { background: var(--accent1); }
.menu-btn.proj1 .icon { background: var(--accent2); }
.menu-btn.proj2 .icon { background: var(--accent3); }

/* Panel */
.panel {
  display: none;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-top: 14px;
}

.panel.active { display: block; }

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  color: var(--primary);
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.input-group input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

.input-group input:focus {
  border-color: var(--primary);
}

.btn {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.back-btn {
  background: transparent;
  color: var(--primary);
  padding: 8px 0;
  font-size: 14px;
  border: none;
  cursor: pointer;
  margin-bottom: 8px;
  font-family: inherit;
}

/* Result card */
.result {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fafbff;
}

.result .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

.result .row:last-child { border-bottom: none; }

.result .key {
  color: var(--muted);
  flex-shrink: 0;
  min-width: 110px;
}

.result .val {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

/* Stepper / flow */
.stepper {
  margin: 12px 0 4px;
  padding: 0;
  list-style: none;
  position: relative;
}

.stepper li {
  position: relative;
  padding: 0 0 16px 40px;
  min-height: 32px;
}

.stepper li:last-child { padding-bottom: 0; }

/* vertical connector */
.stepper li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 22px;
  bottom: -2px;
  width: 2px;
  background: #e0e0e0;
}

.stepper li.done:not(:last-child)::before {
  background: #2e7d32;
}

/* circle */
.stepper li .dot {
  position: absolute;
  left: 4px;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #bdbdbd;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  box-sizing: border-box;
}

.stepper li.done .dot {
  background: #2e7d32;
  border-color: #2e7d32;
}

.stepper li.done .dot::after {
  content: "✓";
}

.stepper li.pending .dot {
  background: #f5f5f5;
  border-color: #bdbdbd;
}

.stepper li.pending .dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bdbdbd;
  display: block;
}

.stepper .stage-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  line-height: 22px;
}

.stepper li.pending .stage-name {
  color: #9e9e9e;
}

.stepper .stage-val {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.stepper li.done .stage-val {
  color: #2e7d32;
}

.stepper li.pending .stage-val {
  color: #bdbdbd;
}

.current-step {
  background: #e8f5e9;
  border: 1.5px solid #2e7d32;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #1b5e20;
}

.current-step.pending {
  background: #f5f5f5;
  border-color: #bdbdbd;
  color: #616161;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  background: #e3f2fd;
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
}

.empty, .error, .loading {
  text-align: center;
  padding: 20px 10px;
  color: var(--muted);
  font-size: 14px;
}

.error { color: #c62828; }

.loading::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.project-card {
  text-align: center;
  padding: 24px 12px;
}

.project-card .big-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.project-card a {
  display: inline-block;
  margin-top: 12px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

.footer {
  text-align: center;
  padding: 12px;
  font-size: 11px;
  color: var(--muted);
}
