:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-soft: #475569;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --primary: #1e3a8a;
  --primary-dark: #1e293b;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  color: white;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  height: calc(56px + env(safe-area-inset-top, 0px));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}

#title {
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: transparent;
  color: white;
  border: 0;
  font-size: 22px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.1); }
.icon-btn[hidden] { display: none; }

.who {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  max-width: 50vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who:active { background: rgba(255, 255, 255, 0.2); }

#main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(120px + var(--safe-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
p.muted { color: var(--text-soft); margin: 0 0 12px; }

label {
  display: block;
  font-size: 13px;
  color: var(--text-soft);
  margin: 12px 0 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"], input[type="number"], input[type="tel"], input[type="time"],
input[type="date"], input[type="password"], select, textarea {
  width: 100%;
  font: inherit;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
          linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 12px) center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.btn, button.primary, button.secondary, button.ghost {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  font-size: 17px;
  padding: 14px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button.primary {
  background: var(--accent);
  color: var(--primary-dark);
}
button.primary:active { background: var(--accent-dark); color: white; }
button.primary.danger { background: var(--danger); color: white; }
button.primary.danger:active { background: #7f1d1d; }
button.primary[disabled] {
  background: #cbd5e1;
  color: #475569;
}
button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:active { background: var(--surface-2); }
button.ghost {
  background: transparent;
  color: var(--primary);
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 16px;
  min-height: 130px;
  box-shadow: var(--shadow);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.tile .tile-emoji { font-size: 28px; }
.tile .tile-label { font-weight: 700; font-size: 18px; }
.tile .tile-sub { color: var(--text-soft); font-size: 13px; }
.tile.accent { background: var(--accent); color: var(--primary-dark); }
.tile.accent .tile-sub { color: rgba(15, 23, 42, 0.7); }
.tile.dark { background: var(--primary-dark); color: white; }
.tile.dark .tile-sub { color: #cbd5e1; }
.tile.wide { grid-column: span 2; min-height: 84px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; }
.tile.wide .tile-emoji { font-size: 28px; }
.tile.wide .tile-label { font-size: 17px; }

.job-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  cursor: pointer;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}
.job-row:active { background: var(--surface-2); }
.job-row .meta { flex: 1; min-width: 0; }
.job-row .meta strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-row .meta span { display: block; font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.status-in-shop { background: #dbeafe; color: #1e3a8a; }
.status-ready { background: #fef3c7; color: var(--accent-dark); }
.status-completed { background: #dcfce7; color: var(--ok); }
.status-pending-net { background: #fee2e2; color: var(--danger); }

#timer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: var(--accent);
  color: var(--primary-dark);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.16);
}
#timer-bar[hidden] { display: none; }
.timer-info { min-width: 0; }
.timer-job { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-stage { font-size: 13px; opacity: 0.85; }
.timer-clock { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }
#timer-stop { width: auto; min-height: 44px; padding: 8px 18px; font-size: 15px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%) translateY(40px);
  z-index: 30;
  background: var(--primary-dark);
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 14px;
  max-width: calc(100% - 32px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
#toast.warn { background: var(--warn); }
#toast.ok { background: var(--ok); }

.queue-badge {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row > * { flex: 1; }

.entry-row {
  background: var(--surface);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.entry-row .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.entry-row .sub { color: var(--text-soft); font-size: 13px; }
.entry-row .actions { display: flex; gap: 8px; margin-top: 10px; }
.entry-row .actions button { flex: 1; min-height: 40px; font-size: 14px; padding: 6px 10px; }

hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

.report-table {
  width: 100%;
  border-collapse: collapse;
}
.report-table th, .report-table td {
  text-align: left;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.report-table th { color: var(--text-soft); text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
.report-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 30px 10px;
}

.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(15,23,42,0.15);
  border-top-color: var(--primary-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 540px) {
  #main { padding: 24px; }
}
