:root {
  --brand: #141414;
  --line: #d4d4d8;
  --ink: #18181b;
  --paper: #ffffff;
  --muted: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #eef0f1;
  color: var(--ink);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: var(--brand);
  color: white;
}

.toolbar-actions { display: flex; align-items: center; gap: 6px; }

.toolbar-logo-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  border-radius: 6px;
  flex-shrink: 0;
}
.toolbar-logo-btn:hover { opacity: 0.85; }
.toolbar-logo { width: 30px; height: 30px; object-fit: cover; border-radius: 6px; display: block; }

.icon-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: white;
  color: var(--brand);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.icon-btn:hover { background: #f0f2f7; }
.icon-btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn svg { width: 16px; height: 16px; }

.btn-compact { padding: 6px 10px; font-size: 12px; }

.btn {
  background: white;
  color: var(--brand);
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #f0f2f7; }
.btn-primary { background: #ffce3d; color: #3b2b00; }
.btn-primary:hover { background: #ffd75c; }
.btn-small { padding: 4px 10px; font-size: 12px; margin-top: 6px; }
.btn:disabled { opacity: 0.6; cursor: default; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

.toast {
  position: fixed;
  top: 64px;
  right: 20px;
  background: var(--brand);
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 20;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }

.sheet-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 12px 60px;
}

.sheet {
  width: 100%;
  max-width: 900px;
  background: var(--paper);
  border: 1px solid #dcdcdc;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  padding: 0 24px 20px;
}

.punch-row {
  height: 26px;
  margin: 0 -24px 8px;
  background-image: radial-gradient(circle, #dcdcdc 5px, transparent 5.5px);
  background-size: 44px 26px;
  background-position: 22px center;
  border-bottom: 3px double #dcdcdc;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 12px;
  margin-bottom: 10px;
  gap: 16px;
}

.brand { display: flex; gap: 12px; }
.logo { width: 56px; height: 56px; flex-shrink: 0; object-fit: cover; border-radius: 8px; }
.company-name { font-weight: 800; font-size: 17px; color: var(--brand); }
.company-line { font-size: 12.5px; color: var(--ink); line-height: 1.5; }

.order-title { text-align: right; }
.job-work-order-label {
  font-size: 20px;
  font-weight: 800;
  color: #b0b0b0;
  letter-spacing: 0.03em;
}
.order-number {
  font-size: 26px;
  font-weight: 800;
  color: var(--brand);
  text-align: right;
  border: none;
  border-bottom: 2px solid var(--line);
  width: 120px;
  margin-top: 4px;
  background: transparent;
  cursor: default;
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }

label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}
label.mt { margin-top: 8px; }
.required-mark { color: #b3261e; }
.cell.invalid input, .cell.invalid textarea { border-bottom: 1px solid #b3261e; }
.cell.invalid label { color: #b3261e; }

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="date"],
select {
  border: none;
  border-bottom: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  padding: 2px 0;
  background: transparent;
  width: 100%;
}
select { cursor: pointer; }
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-bottom: 1px solid var(--brand);
}

.description textarea {
  border: none;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  line-height: 27px;
  background-image: repeating-linear-gradient(white 0px, white 26px, var(--line) 27px);
  background-attachment: local;
  padding-top: 2px;
}
.description textarea:focus { outline: none; }

.totals { justify-content: flex-start; }
.total-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.total-row label { margin-bottom: 0; font-size: 10px; white-space: nowrap; }
.total-row input { text-align: right; max-width: 90px; }
.total-amount-row { border-top: 1px solid var(--line); padding-top: 6px; }
.total-amount-row label { font-weight: 800; color: var(--ink); }
.amount-wrap { display: flex; align-items: center; gap: 2px; font-weight: 700; }
.amount-wrap input { font-weight: 800; }

@media (max-width: 720px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .span-2, .span-3, .span-4, .span-6 { grid-column: span 2; }
  .order-number { width: 90px; font-size: 20px; }
}

.hidden { display: none !important; }

.splash {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef0f1 0%, #dfe1e3 100%);
}

.splash-inner {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
  padding: 36px 28px;
  text-align: center;
}

.splash-logo { width: 64px; height: 64px; margin-bottom: 12px; object-fit: cover; border-radius: 10px; }
.splash-title { font-weight: 800; font-size: 18px; color: var(--brand); letter-spacing: 0.02em; }
.splash-subtitle { font-size: 14px; color: var(--muted); margin-top: 4px; margin-bottom: 28px; line-height: 1.5; }

.splash-buttons { display: flex; flex-direction: column; gap: 14px; }

.splash-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  background: var(--brand);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.splash-btn:hover { background: #334577; }
.splash-btn-icon { font-size: 20px; }
.splash-btn-alt { background: #ffce3d; color: #3b2b00; }
.splash-btn-alt:hover { background: #ffd75c; }
.splash-btn-outline { background: white; color: var(--brand); border: 2px solid var(--brand); padding: 14px 18px; }
.splash-btn-outline:hover { background: #f0f2f7; }

.dictation-inner, .search-inner { max-width: 520px; text-align: left; }
.dictation-inner .splash-title,
.dictation-inner .splash-subtitle,
.search-inner .splash-title,
.search-inner .splash-subtitle { text-align: center; }

.search-bar { display: flex; gap: 8px; }
.search-bar input {
  flex: 1;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  color: var(--ink);
}
.search-bar input:focus { outline: none; border-color: var(--brand); }

.search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.search-result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.search-result-row:hover { background: #f0f2f7; }
.search-result-row .name { font-weight: 700; color: var(--ink); }
.search-result-row .meta { color: var(--muted); text-align: right; }

.search-detail { margin-top: 14px; }
.search-detail.show {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
}
.search-detail h4 { margin: 0 0 8px; color: var(--brand); }
.search-detail .detail-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.search-detail .detail-row span:first-child { color: var(--muted); }
.search-detail .desc { white-space: pre-wrap; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

.dictation-textarea {
  width: 100%;
  min-height: 180px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  color: var(--ink);
}
.dictation-textarea:focus { outline: none; border-color: var(--brand); }

.dictation-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.dictation-actions .btn { flex: 1; padding: 12px; font-size: 15px; }

.dictation-status { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: center; min-height: 18px; }
.dictation-status.error { color: #b3261e; }

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .sheet-wrap { padding: 0; }
  .sheet { box-shadow: none; border: none; max-width: 100%; }
  input, textarea { color: black; }
}
