/* =========================================================
   花歩舗 受注システム — 共通デザインシステム
   和モダン / 深緑 × 金 / 花屋の落ち着き
   ========================================================= */

:root{
  /* Brand */
  --green:        #2f6b4f;
  --green-600:    #295f46;
  --green-700:    #22503b;
  --green-100:    #e6efe9;
  --green-050:    #f1f6f2;
  --gold:         #a9782f;
  --gold-100:     #f6efe0;
  --rose:         #b45b6b;
  --rose-100:     #f7e7ea;

  /* Ink / text */
  --ink:          #2c2b28;
  --ink-2:        #55534d;
  --muted:        #6f6d66;
  --ink-faint:    #a29f97;

  /* Surface */
  --bg:           #f7f5ef;
  --surface:      #ffffff;
  --surface-2:    #efece4;
  --border:       #e6e2d8;
  --border-2:     #d9d4c8;

  /* Status */
  --red:          #c0392b;
  --red-100:      #fbe7e4;
  --blue:         #33689c;
  --blue-100:     #e6eef6;
  --amber:        #b8860b;
  --amber-100:    #f8efd6;

  /* FX */
  --shadow-sm:    0 1px 2px rgba(40,38,30,.05), 0 1px 3px rgba(40,38,30,.06);
  --shadow:       0 6px 24px rgba(40,38,30,.10), 0 2px 6px rgba(40,38,30,.06);
  --radius:       14px;
  --radius-sm:    10px;

  --font-sans:  "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --font-serif: "Shippori Mincho", "Noto Sans JP", serif;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family:var(--font-sans);
  color:var(--ink);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  line-height:1.6;
  font-size:15px;
}
a{ color:inherit; text-decoration:none; }
h1,h2,h3{ margin:0; font-weight:700; }

/* ---------- Layout ---------- */
.app{ min-height:100vh; }
.main{ max-width:1120px; margin:0 auto; padding:0 20px 80px; }

/* Top nav */
.topbar{
  position:sticky; top:0; z-index:40;
  background:rgba(247,245,239,.86);
  backdrop-filter:saturate(160%) blur(10px);
  border-bottom:1px solid var(--border);
}
.topbar-in{
  max-width:1120px; margin:0 auto; padding:10px 20px;
  display:flex; align-items:center; gap:18px;
}
.brand{ display:flex; align-items:center; gap:10px; font-family:var(--font-serif); font-weight:700; color:var(--green); font-size:18px; white-space:nowrap; }
.brand .logo{ width:34px; height:34px; border-radius:10px; background:var(--green-100); display:grid; place-items:center; font-size:19px; }
.nav{ display:flex; gap:4px; margin-left:auto; flex-wrap:wrap; }
.nav a{
  display:flex; align-items:center; gap:6px;
  padding:8px 13px; border-radius:999px; font-size:13.5px; font-weight:500; color:var(--muted);
  transition:.15s;
}
.nav a:hover{ background:var(--surface-2); color:var(--ink); }
.nav a.on{ background:var(--green); color:#fff; }

.page-head{ padding:26px 0 14px; display:flex; align-items:flex-end; gap:16px; flex-wrap:wrap; }
.page-head h1{ font-family:var(--font-serif); font-size:26px; color:var(--green-700); letter-spacing:.02em; }
.page-head p{ margin:6px 0 0; color:var(--muted); font-size:14px; }
.page-head .spacer{ flex:1; }

/* ---------- Card ---------- */
.card{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow-sm);
}
.card.pad{ padding:20px; }
.card-title{ display:flex; align-items:center; gap:9px; font-weight:700; font-size:15.5px; color:var(--ink); margin-bottom:14px; }
.card-title .ic{ width:30px; height:30px; border-radius:9px; background:var(--green-100); display:grid; place-items:center; font-size:16px; }

/* ---------- Grid ---------- */
.grid{ display:grid; gap:18px; }
.grid-2{ grid-template-columns:repeat(2,1fr); }
.grid-3{ grid-template-columns:repeat(3,1fr); }
.grid-4{ grid-template-columns:repeat(4,1fr); }
.row{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }

/* ---------- Form ---------- */
.field{ margin-bottom:14px; }
.field:last-child{ margin-bottom:0; }
label{ display:block; font-size:13px; font-weight:600; color:var(--ink-2); margin-bottom:6px; }
.hint{ font-weight:400; color:var(--ink-faint); font-size:11.5px; margin-left:4px; }
.req{ display:inline-block; background:var(--rose-100); color:var(--rose); font-size:10.5px; font-weight:700; padding:1px 7px; border-radius:999px; margin-left:6px; vertical-align:middle; }

.input,.textarea,.select{
  width:100%; font-family:inherit; font-size:15px; color:var(--ink);
  background:#fdfdfb; border:1.5px solid var(--border-2); border-radius:var(--radius-sm);
  padding:11px 12px; transition:.15s;
}
.input:focus,.textarea:focus,.select:focus{
  outline:none; border-color:var(--green); background:#fff;
  box-shadow:0 0 0 3px rgba(47,107,79,.12);
}
.textarea{ min-height:78px; resize:vertical; line-height:1.7; }
/* 商品ブロック内の小さめテキストエリア（特記・備考。改行して書ける） */
.textarea.ta-sm{ min-height:52px; padding:9px 11px; font-size:14.5px; line-height:1.6; }
.select{ appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236f6d66' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:34px; }
.input-money{ position:relative; }
.input-money::before{ content:"¥"; position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--ink-faint); font-size:14px; z-index:1; }
.input-money .input{ padding-left:24px; text-align:right; }

/* Segment (toggle group) */
.segment{ display:inline-flex; background:var(--surface-2); border-radius:999px; padding:4px; gap:2px; flex-wrap:wrap; }
.segment button{
  font-family:inherit; font-size:13.5px; font-weight:600; color:var(--muted);
  border:none; background:transparent; padding:8px 15px; border-radius:999px; cursor:pointer; transition:.15s;
}
.segment button:hover{ color:var(--ink); }
.segment button.on{ background:#fff; color:var(--green); box-shadow:var(--shadow-sm); }

/* Chips */
.chips{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  font-size:13.5px; font-weight:600; color:var(--muted);
  border:1.5px solid var(--border-2); background:#fdfdfb; padding:7px 14px; border-radius:999px; cursor:pointer; transition:.15s;
}
.chip:hover{ border-color:var(--green); color:var(--green); }
.chip.on{ background:var(--green); border-color:var(--green); color:#fff; }

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

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  font-family:inherit; font-size:14.5px; font-weight:700; cursor:pointer;
  padding:11px 18px; border-radius:var(--radius-sm); border:1.5px solid transparent; transition:.15s; white-space:nowrap;
}
.btn-primary{ background:var(--green); color:#fff; }
.btn-primary:hover{ background:var(--green-600); }
.btn-ghost{ background:#fff; color:var(--ink-2); border-color:var(--border-2); }
.btn-ghost:hover{ background:var(--surface-2); }
.btn-gold{ background:var(--gold); color:#fff; }
.btn-gold:hover{ filter:brightness(.94); }
.btn-sm{ padding:8px 13px; font-size:13px; }
.btn-lg{ padding:14px 22px; font-size:16px; }
.btn-block{ width:100%; }

/* ---------- Badges ---------- */
.badge{ display:inline-flex; align-items:center; gap:4px; font-size:11.5px; font-weight:700; padding:3px 10px; border-radius:999px; line-height:1.5; }
.badge.green{ background:var(--green-100); color:var(--green); }
.badge.gold{ background:var(--gold-100); color:var(--gold); }
.badge.rose{ background:var(--rose-100); color:var(--rose); }
.badge.blue{ background:var(--blue-100); color:var(--blue); }
.badge.amber{ background:var(--amber-100); color:var(--amber); }
.badge.gray{ background:var(--surface-2); color:var(--muted); }
.badge.red{ background:var(--red-100); color:var(--red); }

/* ---------- Utilities ---------- */
.small{ font-size:12.5px; }
.faint{ color:var(--ink-faint); }
.muted{ color:var(--muted); }
.center{ text-align:center; }
.right{ text-align:right; }
.mb0{ margin-bottom:0; }
.money{ font-variant-numeric:tabular-nums; font-feature-settings:"tnum"; letter-spacing:.01em; }
.spacer{ flex:1; }
.nowrap{ white-space:nowrap; }

/* 特記マーク（改行をそのまま出す） */
.mark-tokki{
  display:inline-flex; align-items:flex-start; gap:6px;
  background:var(--red-100); color:var(--red); font-weight:700; font-size:13px;
  padding:8px 12px; border-radius:var(--radius-sm); line-height:1.5;
  white-space:pre-wrap;
}
/* 一覧・伝票で改行を保つ本文 */
.pre-wrap{ white-space:pre-wrap; }

/* 顧客検索ヒット */
.cust-hit:hover{ background:var(--green-050); }

/* ---------- Stat tiles ---------- */
.stat{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; box-shadow:var(--shadow-sm); }
.stat .k{ font-size:12.5px; color:var(--muted); font-weight:600; display:flex; align-items:center; gap:7px; }
.stat .v{ font-family:var(--font-serif); font-size:30px; font-weight:700; color:var(--green-700); margin-top:6px; }
.stat .v.money{ font-family:var(--font-sans); }
.stat .sub{ font-size:12px; color:var(--ink-faint); margin-top:2px; }

/* ---------- Table ---------- */
.tbl{ width:100%; border-collapse:collapse; font-size:14px; }
.tbl th{ text-align:left; font-size:12px; font-weight:700; color:var(--muted); padding:10px 12px; border-bottom:2px solid var(--border); white-space:nowrap; }
.tbl td{ padding:12px; border-bottom:1px solid var(--border); vertical-align:middle; }
.tbl tr:last-child td{ border-bottom:none; }

/* ---------- Toast ---------- */
.toast{
  position:fixed; left:50%; bottom:28px; transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:#fff; font-weight:600; font-size:14px;
  padding:13px 22px; border-radius:999px; box-shadow:var(--shadow); z-index:100;
  opacity:0; transition:.28s; pointer-events:none;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ---------- Order list rows ---------- */
.order-card{
  background:var(--surface); border:1px solid var(--border); border-left:5px solid var(--border-2);
  border-radius:var(--radius); padding:14px 16px; box-shadow:var(--shadow-sm); transition:.15s;
}
.order-card:hover{ box-shadow:var(--shadow); }
.order-card.due-today{ border-left-color:var(--red); }
.order-card.due-soon{ border-left-color:var(--amber); }
.order-card.done{ opacity:.62; }

.daychip{
  display:inline-flex; flex-direction:column; align-items:center; justify-content:center;
  width:56px; min-height:56px; border-radius:12px; background:var(--green-100); color:var(--green-700); flex:none;
}
.daychip .d{ font-family:var(--font-serif); font-size:22px; font-weight:700; line-height:1; }
.daychip .m{ font-size:11px; font-weight:600; margin-top:2px; }
.daychip.today{ background:var(--red); color:#fff; }
.daychip.soon{ background:var(--amber-100); color:var(--amber); }

.chk{
  display:inline-flex; align-items:center; gap:6px; cursor:pointer; user-select:none;
  font-size:12.5px; font-weight:600; color:var(--muted);
  border:1.5px solid var(--border-2); border-radius:999px; padding:5px 11px; transition:.15s; background:#fff;
}
.chk:hover{ border-color:var(--green); }
.chk.on{ background:var(--green); border-color:var(--green); color:#fff; }

/* ---------- Print (PDF screens) ---------- */
.print-toolbar{
  display:flex; align-items:center; gap:12px; justify-content:center;
  padding:14px; margin:16px 0; background:var(--surface); border:1px dashed var(--border-2); border-radius:var(--radius);
}
.paper{
  background:#fff; color:#111; margin:0 auto; box-shadow:var(--shadow);
  border:1px solid var(--border); max-width:100%;
}

/* ---------- 予測変換（顧客マスタの候補） ---------- */
.sug-wrap{ position:relative; }
.sug-box{
  position:absolute; z-index:40; left:0; right:0; top:calc(100% + 4px);
  background:var(--surface); border:1px solid var(--border-2); border-radius:10px;
  box-shadow:var(--shadow); overflow:hidden auto; max-height:290px;
}
.sug-item{ padding:9px 12px; cursor:pointer; border-bottom:1px solid var(--border); }
.sug-item:last-child{ border-bottom:none; }
.sug-item.on, .sug-item:hover{ background:var(--green-050); }
.sug-item .nm{ font-weight:700; }

/* ---------- タップで遷移するパネル ---------- */
.tap{ cursor:pointer; transition:transform .12s ease, box-shadow .12s ease; }
.tap:hover{ transform:translateY(-2px); box-shadow:var(--shadow); }
.tap:active{ transform:translateY(0); }
.tap-row{ cursor:pointer; border-radius:8px; transition:background .12s; }
.tap-row:hover{ background:var(--green-050); }

/* ---------- 商品ブロック（1点ごとの入力） ---------- */
.item-block{ border:1.5px solid var(--border); border-radius:var(--radius-sm); padding:12px; margin-bottom:12px; background:#fdfdfb; }
.item-block .item-top{ display:flex; gap:8px; align-items:flex-start; }
.item-block .item-no{ width:24px; height:24px; flex:none; border-radius:7px; background:var(--green-100); color:var(--green-700); display:grid; place-items:center; font-size:12px; font-weight:700; margin-top:9px; }
.item-detail{ margin-top:10px; padding-top:10px; border-top:1px dashed var(--border); display:grid; gap:9px; }
.item-detail label{ margin-bottom:3px; font-size:12px; }
.item-detail .seg-row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* ---------- 2カラムレイアウト（畳めるグリッド） ---------- */
.split-form{ display:grid; gap:18px; grid-template-columns:1fr 340px; align-items:start; }
.split-dash{ display:grid; gap:18px; grid-template-columns:1.3fr 1fr; align-items:start; }

@media print{
  body{ background:#fff; }
  .topbar,.print-toolbar,.page-head,.no-print{ display:none !important; }
  .main{ padding:0; max-width:none; }
  .paper{ box-shadow:none; border:none; margin:0; }
  @page{ margin:12mm; }
}

/* ---------- Responsive ---------- */
html,body{ overflow-x:hidden; }
img,svg,video{ max-width:100%; height:auto; }
/* 長文・数値の折返し安全化 */
.order-card, .card{ min-width:0; }

/* タブレット以下：2カラムを1カラムへ */
@media (max-width:860px){
  .grid-2,.grid-3,.grid-4{ grid-template-columns:1fr; }
  .row{ grid-template-columns:1fr; }
  .split-form,.split-dash{ grid-template-columns:1fr; }
  .brand span.full{ display:none; }
  .main{ padding-left:14px; padding-right:14px; }
  .page-head{ padding:20px 0 12px; }
  .page-head h1{ font-size:22px; }
  /* サイドの追従を解除して通常配置に */
  .side-sticky{ position:static !important; top:auto !important; }
}

/* スマホ：下部タブバー（片手操作のアプリUI） */
@media (max-width:720px){
  body{ padding-bottom:calc(62px + env(safe-area-inset-bottom)); }
  .topbar{
    position:fixed; top:auto; bottom:0; left:0; right:0;
    border-top:1px solid var(--border); border-bottom:none;
    box-shadow:0 -1px 12px rgba(40,38,30,.10);
    background:rgba(255,255,255,.97);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .topbar-in{ padding:0; }
  .brand{ display:none; }
  .nav{ margin:0; width:100%; justify-content:space-around; gap:0; flex-wrap:nowrap; }
  .nav a{
    flex:1 1 0; min-width:0; flex-direction:column; align-items:center; gap:3px;
    padding:8px 2px 7px; border-radius:0; font-size:20px; color:var(--muted); font-weight:600;
  }
  .nav a span{ font-size:10px; line-height:1.1; }
  .nav a:hover{ background:transparent; }
  .nav a.on{ background:transparent; color:var(--green); }
  /* フォーム縦積み時の会計サマリは全幅で見やすく */
  .side-sticky{ width:100%; }
  /* セグメント/チップは折返し */
  .segment{ flex-wrap:wrap; }
  .page-head .btn{ }
}

/* 小さめスマホ：文字と余白をさらに最適化 */
@media (max-width:420px){
  body{ font-size:14.5px; }
  .card.pad{ padding:16px; }
  .stat{ padding:15px 16px; }
  .stat .v{ font-size:26px; }
  .segment button{ padding:7px 12px; font-size:12.5px; }
  .btn{ padding:10px 14px; }
}

/* Segment（小） — 指標カード内の月／週トグル用 */
.segment.seg-mini{ padding:2px; gap:1px; }
.segment.seg-mini button{ font-size:11.5px; font-weight:700; padding:3px 10px; }

/* 期間ナビ（‹ 今月 ›） */
.period{ display:inline-flex; align-items:center; gap:4px; }
.period .nav-btn{
  font-family:inherit; font-size:15px; line-height:1; color:var(--muted);
  border:1.5px solid var(--border-2); background:#fdfdfb;
  width:30px; height:30px; border-radius:999px; cursor:pointer; transition:.15s;
}
.period .nav-btn:hover{ border-color:var(--green); color:var(--green); }
.period .lbl{ font-size:13.5px; font-weight:700; color:var(--ink); min-width:150px; text-align:center; }

/* ---------- イメージ写真 ---------- */
.photo-grid{ display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }
.photo-thumb{
  position:relative; width:104px; height:104px; border-radius:var(--radius-sm);
  overflow:hidden; border:1.5px solid var(--border-2); background:var(--surface-2);
}
.photo-thumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.photo-thumb .ph-del{
  position:absolute; top:4px; right:4px; width:24px; height:24px; border-radius:999px;
  border:none; background:rgba(0,0,0,.55); color:#fff; font-size:12px; line-height:1;
  cursor:pointer; font-family:inherit;
}
.photo-thumb .ph-del:hover{ background:var(--red); }
.photo-thumb .ph-state{
  position:absolute; inset:0; display:grid; place-items:center;
  background:rgba(255,255,255,.72); color:var(--ink-2); font-size:12px; font-weight:700;
}
/* 一覧カードの小さなサムネイル */
.thumbs{ display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.thumbs a{ display:block; width:62px; height:62px; border-radius:8px; overflow:hidden; border:1px solid var(--border); }
.thumbs img{ width:100%; height:100%; object-fit:cover; display:block; }
