:root {
  --bg: #070A10;
  --panel: #0E1420;
  --panel2: #131B2C;
  --line: #22304A;
  --text: #E8EEF7;
  --muted: #8FA3BF;
  --accent: #00E5FF;
  --accent-dark: #003B44;
  --danger: #FF5A7A;
  --ok: #2EE6A8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
.hidden { display: none !important; }

/* ===== ヘッダー ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(7,10,16,.92); z-index: 10;
}
.app-header h1 { font-size: 18px; margin: 0; letter-spacing: .04em; }
.app-header h1::before { content: "▸ "; color: var(--accent); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== タブ ===== */
.tabs {
  display: flex; gap: 6px; padding: 10px 20px 0;
  max-width: 1100px; margin: 0 auto;
}
.tab-btn {
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 10px 18px; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-bottom: none;
}
.tab-btn.active { background: var(--panel); color: var(--accent); }
@media (max-width: 560px) {
  .tabs { padding: 8px 10px 0; }
  .tab-btn { padding: 9px 10px; font-size: 14px; flex: 1; }
}

/* ===== ボタン ===== */
.btn {
  font: inherit; cursor: pointer; border-radius: 8px;
  padding: 9px 16px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: #00222A; font-weight: 700;
}
.btn-primary:hover { background: #4DEBFF; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--accent-dark); }
.btn-danger {
  background: transparent; border-color: #4A2230; color: var(--danger);
  padding: 9px 14px;
}

/* ===== レイアウト・カード ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 16px 20px 8px; }
@media (max-width: 560px) { .container { padding: 12px 10px 4px; } }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
.card h2 {
  font-size: 14px; margin: 0 0 12px; color: var(--accent);
  letter-spacing: .08em;
}
.card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.card label.inline { display: inline-block; margin-bottom: 0; }
.card input, .card textarea, .card select {
  display: block; width: 100%; margin-top: 4px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font: inherit; font-size: 15px;
}
.card label.inline input, .card label.inline select { width: auto; min-width: 170px; }
.card input:focus, .card textarea:focus, .card select:focus {
  outline: none; border-color: var(--accent);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }
.row-flex { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* ===== 配達チェック ===== */
.progress-wrap { margin-top: 14px; }
.progress-text { font-size: 14px; margin-bottom: 6px; }
.progress-text span { font-weight: 700; color: var(--accent); }
.progress-bar {
  height: 10px; border-radius: 6px; background: var(--panel2);
  border: 1px solid var(--line); overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  transition: width .25s ease;
}
.delivery-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 8px 14px;
  align-items: center;
}
.delivery-card.done { border-color: var(--ok); }
.delivery-card .d-name { font-size: 17px; font-weight: 700; }
.delivery-card .d-addr { font-size: 13px; color: var(--muted); }
.delivery-card .d-meta { font-size: 13px; color: var(--muted); }
.delivery-card .d-meta .staff-name { color: var(--text); }
.delivery-card .d-qty { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.delivery-card .d-qty input {
  width: 76px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; font: inherit; font-size: 15px; text-align: right;
}
.check-btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: 10px; padding: 14px 20px; font-size: 16px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  min-width: 132px;
}
.check-btn:hover { border-color: var(--accent); }
.delivery-card.done .check-btn {
  background: var(--ok); border-color: var(--ok); color: #03251A;
}
.d-time { font-size: 13px; color: var(--ok); text-align: right; min-height: 20px; }
.empty-note {
  background: var(--panel); border: 1px dashed var(--line); border-radius: 12px;
  padding: 20px; text-align: center; color: var(--muted);
}

/* ===== 集計 ===== */
.summary-headline {
  display: flex; gap: 26px; flex-wrap: wrap; margin-top: 14px;
}
.summary-headline div span { display: block; font-size: 12px; color: var(--muted); }
.summary-headline div strong { font-size: 20px; color: var(--accent); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left;
}
.data-table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.data-table td.num, .data-table th.num { text-align: right; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; border: 1px solid var(--line); color: var(--muted);
}
.badge.done { color: #03251A; background: var(--ok); border-color: var(--ok); }

/* ===== 設定のリスト編集 ===== */
.edit-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap;
}
.edit-row input, .edit-row select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 14px;
}
.edit-row .grow { flex: 1; min-width: 140px; }
.edit-row .del {
  background: transparent; border: 1px solid #4A2230; color: var(--danger);
  border-radius: 8px; padding: 7px 11px; cursor: pointer; font: inherit; font-size: 13px;
}
.add-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-row input {
  flex: 1; min-width: 180px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font: inherit; font-size: 15px;
}
.dest-add { display: grid; grid-template-columns: 1.2fr 1.4fr .9fr .6fr auto; gap: 8px; margin-top: 10px; }
.dest-add input, .dest-add select {
  background: var(--bg); color: var(--text); width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font: inherit; font-size: 14px;
}
@media (max-width: 760px) { .dest-add { grid-template-columns: 1fr 1fr; } }

/* ===== フッター ===== */
.app-footer {
  max-width: 1100px; margin: 0 auto; padding: 4px 20px 24px;
  font-size: 12px; color: var(--muted);
}

/* ===== 請求書シート（A4） ===== */
.preview-wrap { min-width: 0; }
.sheet {
  background: #fff; color: #111;
  width: 100%; max-width: 820px; margin: 0 auto;
  aspect-ratio: 210 / 297;
  padding: 44px 48px;
  box-shadow: 0 8px 40px rgba(0,0,0,.55);
  font-size: 14px; line-height: 1.55;
  overflow: hidden;
}
@media (max-width: 900px) {
  .sheet { padding: 24px 20px; font-size: 12px; }
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px double #111; padding-bottom: 10px;
}
.sheet-head h1 { font-size: 30px; margin: 0; letter-spacing: .3em; }
.sheet-meta { text-align: right; font-size: 13px; }
.sheet-parties {
  display: flex; justify-content: space-between; gap: 24px; margin-top: 22px;
}
.sheet-client { flex: 1.2; }
.sheet-issuer { flex: 1; font-size: 13px; }
.client-name { font-size: 19px; font-weight: 700; border-bottom: 1px solid #111; padding-bottom: 4px; min-height: 30px; }
.total-box {
  margin-top: 16px; border: 2px solid #111; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.total-box strong { font-size: 22px; }
.due-line { margin-top: 8px; font-size: 13px; }
.issuer-name { font-size: 16px; font-weight: 700; }
.sheet-table { width: 100%; border-collapse: collapse; margin-top: 24px; }
.sheet-table th, .sheet-table td { border: 1px solid #555; padding: 7px 9px; }
.sheet-table th { background: #EDEFF3; font-weight: 700; }
.sheet-table .c-num { width: 16%; text-align: right; }
.sheet-table .c-date { width: 15%; }
.sheet-table td.num { text-align: right; }
.sheet-table tr.empty td { color: #BBB; text-align: center; }
.sheet-totals { display: flex; justify-content: flex-end; margin-top: 14px; }
.sheet-totals table { border-collapse: collapse; min-width: 300px; }
.sheet-totals td { border: 1px solid #555; padding: 6px 10px; }
.sheet-totals td.num { text-align: right; min-width: 130px; }
.sheet-totals .t-grand { font-weight: 700; background: #EDEFF3; font-size: 16px; }
.sheet-note { margin-top: 22px; }
.sheet-note .note-title { font-weight: 700; border-bottom: 1px solid #999; padding-bottom: 2px; }
.sheet-note #pv-note { white-space: pre-wrap; padding-top: 6px; min-height: 40px; font-size: 13px; }

/* ===== 印刷 ===== */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  #view-check, #view-summary, #view-settings { display: none !important; }
  #view-invoice { display: block !important; }
  #view-invoice .card { display: none !important; }
  .container { padding: 0; max-width: none; }
  .preview-wrap { padding: 0; }
  .sheet {
    width: 210mm; height: 297mm; max-width: none;
    aspect-ratio: auto; padding: 16mm 17mm;
    box-shadow: none; margin: 0; font-size: 13px;
    overflow: hidden;
  }
}
