/* TANA（たな）体験版 — 生成り × 墨 × 深い琥珀 × 灰青 */
:root {
  --bg: #faf7f2;
  --paper: #ffffff;
  --side: #f2ece2;
  --line: #e6dfd3;
  --line-2: #d8cfc0;
  --ink: #2a2a2a;
  --muted: #6a645c;
  --amber: #9a5b1e;
  --amber-d: #7c4815;
  --amber-l: #f6ebdd;
  --slate: #5d7285;
  --slate-d: #485a6a;
  --slate-l: #e7edf2;
  --red: #a23b2a;
  --red-l: #f8e6e1;
  --ok: #4f7259;
  --ok-l: #e5efe7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(42, 42, 42, .05), 0 4px 18px rgba(42, 42, 42, .06);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--slate-d); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; }

/* ===== 体験版の帯 ===== */
.demo-band {
  position: sticky; top: 0; z-index: 60;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 2px 16px; padding: 6px 16px;
  background: var(--ink); color: #f3efe8;
  font-size: 12.5px; line-height: 1.55;
}
.demo-band p { flex: 1 1 420px; min-width: 0; }
.demo-band a { color: #f3efe8; white-space: nowrap; text-underline-offset: 3px; }

/* ===== 骨組み ===== */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 34px); }
.side {
  background: var(--side); border-right: 1px solid var(--line);
  padding: 22px 14px; position: sticky; top: 34px; align-self: start; height: calc(100vh - 34px); overflow-y: auto;
}
.brand { display: flex; flex-direction: column; padding: 0 8px 18px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.brand-logo { font-family: var(--serif); font-size: 28px; letter-spacing: .3em; line-height: 1.2; color: var(--amber-d); }
.brand-ja { font-size: 12.5px; color: var(--muted); }
.brand-salon { font-size: 12px; color: var(--slate-d); margin-top: 6px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; border-radius: 10px; padding: 10px 12px; min-height: 46px;
  font-size: 16px; text-align: left; color: var(--ink);
}
.side-nav button:hover { background: rgba(154, 91, 30, .08); }
.side-nav button[aria-current="page"] { background: var(--paper); box-shadow: var(--shadow); color: var(--amber-d); font-weight: 700; }
.side-nav .badge { margin-left: auto; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.mainwrap { min-width: 0; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 24px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.top-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.top-brand { display: none; font-family: var(--serif); letter-spacing: .2em; color: var(--amber-d); font-size: 18px; }
.top-brand small { font-family: var(--font); letter-spacing: 0; font-size: 11px; color: var(--muted); }
#pageTitle { font-size: 21px; font-weight: 700; }
.top-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.store-seg { display: flex; background: var(--side); border-radius: 999px; padding: 3px; gap: 3px; }
.store-seg button {
  border: 0; background: transparent; border-radius: 999px; padding: 6px 16px; min-height: 42px;
  font-size: 15px; font-weight: 600; color: var(--muted);
}
.store-seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.tool-btn {
  border: 1px solid var(--line-2); background: transparent; border-radius: 999px;
  padding: 6px 14px; min-height: 42px; font-size: 14px; color: var(--muted);
}
.tool-btn:hover { border-color: var(--amber); color: var(--amber-d); }

.app { padding: 24px 24px 64px; max-width: 1180px; outline: none; }

.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--paper); border-top: 1px solid var(--line-2);
  box-shadow: 0 -2px 12px rgba(42, 42, 42, .06);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 0; background: transparent; min-height: 60px; padding: 6px 0; font-size: 12px; color: var(--muted); min-width: 0;
}
.tabbar button[aria-current="page"] { color: var(--amber-d); font-weight: 700; }
.tabbar button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--amber); }
.tabbar .dot { position: absolute; top: 7px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .tabbar { display: grid; }
  body { padding-bottom: 70px; }
  .top-brand { display: inline; }
  .topbar { padding: 10px 16px; }
  #pageTitle { font-size: 18px; }
  .app { padding: 18px 16px 48px; }
}
@media (max-width: 480px) {
  .tool-btn { padding: 4px 10px; font-size: 13px; min-height: 40px; }
  .store-seg button { padding: 4px 12px; min-height: 40px; font-size: 14px; }
}

/* ===== 共通部品 ===== */
.h2 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.lead { color: var(--muted); font-size: 15px; margin-bottom: 16px; }
.small { font-size: 13.5px; color: var(--muted); }
.mt { margin-top: 18px; }
.mt-s { margin-top: 10px; }
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card + .card { margin-top: 0; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--ink); background: var(--paper); font-size: 15px; font-weight: 600;
  text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--amber-d); border-color: var(--amber-d); }
.btn.slate { background: var(--slate); border-color: var(--slate); color: #fff; }
.btn.slate:hover:not(:disabled) { background: var(--slate-d); }
.btn.ghost { border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn.danger { border-color: #d9b3aa; color: var(--red); }
.btn.sm { min-height: 40px; padding: 4px 14px; font-size: 14px; }
.btn:disabled { opacity: .45; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--slate-d); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; text-align: left; font-weight: 600; min-height: 32px; }
.linkbtn:hover { color: var(--amber-d); }

.tag {
  display: inline-block; font-size: 12px; line-height: 1.6; padding: 0 8px; border-radius: 999px;
  background: var(--side); color: var(--muted); font-weight: 600; white-space: nowrap; vertical-align: middle;
}
.tag.amber { background: var(--amber-l); color: var(--amber-d); }
.tag.slate { background: var(--slate-l); color: var(--slate-d); }
.tag.red { background: var(--red-l); color: var(--red); }
.tag.ok { background: var(--ok-l); color: var(--ok); }
.badge { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; text-align: center; line-height: 1.7; font-weight: 700; }

.seg { display: inline-flex; flex-wrap: wrap; background: var(--side); border-radius: 999px; padding: 3px; gap: 3px; margin-bottom: 14px; max-width: 100%; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 16px; min-height: 42px; font-size: 15px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

.notice { background: var(--slate-l); border-radius: 10px; padding: 12px 14px; font-size: 14.5px; color: #33414d; }
.notice.amber { background: var(--amber-l); color: #5d3810; }
.notice.red { background: var(--red-l); color: #6e2418; }
.empty { padding: 22px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 10px; font-size: 15px; }
.err { color: var(--red); font-size: 14.5px; font-weight: 600; min-height: 0; }
.err:empty { display: none; }
.err:not(:empty) { margin: 8px 0; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.kpi .k { font-size: 13.5px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.35; }
.kpi .v small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi .s { font-size: 13px; color: var(--muted); }
.kpi.alert .v { color: var(--red); }

/* 一覧（小さな行） */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .main { flex: 1 1 220px; min-width: 0; }
.rows .side-v { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== 表 ===== */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line-2); white-space: nowrap; background: var(--paper); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th.n, table.t td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); background: #fcfaf6; }
table.t tr.hl td { background: #fff8ef; }
table.t td.c, table.t th.c { text-align: center; }
.plus { color: var(--slate-d); }
.minus { color: var(--amber-d); }
.bad { color: var(--red); font-weight: 700; }
.pname { font-weight: 600; }
.sub-line { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
td input[type="number"], td input[type="text"] { width: 100%; min-width: 70px; }
td input.qty { max-width: 110px; text-align: right; }

/* スマホでは表を「カード」に組み替える */
@media (max-width: 680px) {
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 8px 12px; background: var(--paper); }
  table.rt tr.total { background: #fcfaf6; }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  table.rt td::before { content: attr(data-l); flex: none; color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; }
  table.rt td.main { display: block; text-align: left; font-size: 16px; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  table.rt td.main::before { display: none; }
  table.rt td.n { text-align: right; }
  table.rt td:empty { display: none; }
  table.rt td input.qty { max-width: 130px; }
  table.rt td input[type="text"] { max-width: 60%; }
  table.rt tr.total td { border-top: 0; background: transparent; }
}

/* ===== フォーム ===== */
.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--muted); font-weight: 400; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--paper); font-size: 16px; min-width: 0;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--amber); outline-offset: 0; border-color: var(--amber); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--amber); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }

.preview { background: #fcfaf6; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14.5px; }
.preview:empty { display: none; }
.preview ul { margin: 4px 0 0; padding-left: 1.2em; }

/* ===== グラフ ===== */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 12px; fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ===== 施術 ===== */
.treat-list { display: grid; gap: 10px; }
.treat {
  display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 6px 14px; align-items: center;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px;
  border-left: 4px solid var(--slate);
}
.treat.done { border-left-color: var(--ok); background: #fbfdfb; }
.treat .time { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.treat .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
@media (max-width: 600px) {
  .treat { grid-template-columns: 58px minmax(0, 1fr); }
  .treat .act { grid-column: 1 / -1; }
  .treat .act .btn { width: 100%; }
}

/* ===== モーダル ===== */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(30, 28, 25, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-box { background: var(--paper); border-radius: 16px; width: 100%; max-width: 640px; padding: 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); min-width: 0; }
.modal-box.wide { max-width: 860px; }
.modal-box h3 { font-size: 19px; margin-bottom: 10px; }
.modal-box .btn-row { margin-top: 16px; }
.guide-list { margin: 8px 0 0; padding-left: 1.3em; display: grid; gap: 6px; font-size: 15.5px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 120; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 発注書 ===== */
.sheet { border: 1px solid var(--line-2); border-radius: 8px; padding: 20px; background: #fff; font-size: 14px; }
.sheet h4 { font-family: var(--serif); font-size: 24px; letter-spacing: .4em; text-align: center; margin: 0 0 12px; }
.sheet .meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet .to { font-size: 17px; font-weight: 700; border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { border: 1px solid #bbb; padding: 6px 8px; }
.sheet th { background: #f3efe8; font-size: 12.5px; }
.sheet .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet .foot { margin-top: 10px; font-size: 12px; color: #555; }
.sheet-wrap { overflow-x: auto; }

.print-area { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  .sheet { border: 0; padding: 0; font-size: 12pt; }
}

.noscript { padding: 20px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 400px) {
  .kpi { padding: 12px; }
  .kpi .v { font-size: 22px; }
}
