*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --sidebar: #12161c;
  --sidebar-soft: #9aa4b2;
  --text: #1a1d23;
  --muted: #7c8794;
  --border: #e6e9ee;
  --orange: #e8702a;
  --orange-soft: #fff3ec;
  --green: #2e9e5a;
  --blue: #2f6fd0;
  --red: #d94b3c;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --sidebar-w: 244px;
  --topbar-h: 64px;
}

html { background: var(--bg); color: var(--text); font-family: 'Noto Sans JP', sans-serif; }
body { min-height: 100vh; }
body.ready { padding-left: var(--sidebar-w); padding-top: var(--topbar-h); }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 40;
  background: var(--sidebar); color: #e8ecf1; display: flex; flex-direction: column;
  padding: 18px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand svg { width: 26px; height: 26px; color: #fff; flex-shrink: 0; }
.brand-sub { font-size: .72rem; color: var(--sidebar-soft); line-height: 1.2; }
.brand-title { font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.3; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: .68rem; color: #6b7684; margin: 16px 10px 6px; letter-spacing: .04em; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: #c6cdd6; text-decoration: none; font-size: .87rem; transition: background .15s, color .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: rgba(232, 112, 42, .16); color: #ffa870; font-weight: 700; }
.nav-badge {
  margin-left: auto; background: var(--orange); color: #fff; min-width: 20px; height: 20px;
  border-radius: 10px; font-size: .68rem; font-weight: 700; display: flex;
  align-items: center; justify-content: center; padding: 0 6px;
}
.nav-badge.hidden { display: none; }
.qr-link {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px;
  padding: 12px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px;
  color: #c6cdd6; text-decoration: none; font-size: .82rem;
}
.qr-link svg { width: 16px; height: 16px; }
.qr-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

/* ── TOPBAR ── */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h); z-index: 30;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
}
.topbar-title { font-size: 1rem; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; color: var(--text); }
.menu-toggle svg { width: 22px; height: 22px; }
.bell { position: relative; background: none; border: none; cursor: pointer; padding: 8px; color: var(--text); }
.bell svg { width: 21px; height: 21px; }
.bell-badge {
  position: absolute; top: 2px; right: 2px; background: var(--red); color: #fff;
  min-width: 17px; height: 17px; border-radius: 9px; font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.bell-badge.hidden { display: none; }
.bell.ringing { color: var(--orange); }

/* 呼び出しパネル。ベルはページ移動ではなく、その場で用件を出す。 */
.call-panel {
  position: absolute; top: calc(var(--topbar-h) - 8px); right: 14px; z-index: 45;
  width: min(340px, calc(100vw - 28px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16,24,40,.14); display: none; overflow: hidden;
}
.call-panel.open { display: block; }
.cp-head {
  padding: 12px 15px; font-size: .85rem; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.cp-list { max-height: min(60vh, 420px); overflow-y: auto; }
.cp-empty { padding: 22px 15px; text-align: center; font-size: .82rem; color: var(--muted); }
.cp-item {
  display: flex; align-items: center; gap: 11px; padding: 12px 15px;
  border-bottom: 1px solid var(--border); border-left: 4px solid transparent;
}
.cp-item:last-child { border-bottom: none; }
.cp-item.staff { border-left-color: var(--orange); background: var(--orange-soft); }
.cp-item.checkout { border-left-color: var(--green); background: #eef8f1; }
.cp-emoji { font-size: 1.25rem; line-height: 1; }
.cp-main { flex: 1; min-width: 0; }
.cp-kind { font-size: .88rem; font-weight: 700; }
.cp-where { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.logout-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font-size: .8rem; cursor: pointer; font-family: inherit; color: var(--text);
}
.logout-btn:hover { background: var(--bg); }

/* スマホ用の下部タブ。広い画面ではサイドバーがあるので隠す。 */
.tabbar { display: none; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 35; display: none; }
.scrim.show { display: block; }

/* ── PAGE ── */
.page { padding: 26px 24px 60px; max-width: 1360px; }
.page > h1 { font-size: 1.45rem; font-weight: 900; margin-bottom: 4px; }
.page > .page-sub { font-size: .85rem; color: var(--muted); margin-bottom: 22px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: .98rem; font-weight: 700; }
.card-head .link { margin-left: auto; font-size: .82rem; color: var(--blue); text-decoration: none; }
.card-body { padding: 16px 18px; }

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.stat-label { display: flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.stat-label svg { width: 16px; height: 16px; }
.stat-value { font-size: 1.9rem; font-weight: 900; line-height: 1.1; }
.stat-value small { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat-note { font-size: .76rem; color: var(--muted); margin-top: 8px; }
.stat.accent .stat-value { color: var(--orange); }
.stat.green .stat-value { color: var(--green); }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 9px 14px; font-size: .82rem; cursor: pointer;
  font-family: inherit; transition: background .15s;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.05); background: var(--orange); }
.btn.green { border-color: var(--green); color: var(--green); font-weight: 700; }
.btn.green:hover { background: var(--green); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: .76rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 3px 10px; font-size: .72rem; font-weight: 700; }
.pill.pending { background: #eaf1fd; color: var(--blue); }
.pill.preparing { background: var(--orange-soft); color: var(--orange); }
.pill.served { background: #e9f7ee; color: var(--green); }
.pill.grey { background: var(--bg); color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 34px 0; font-size: .86rem; }

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: .74rem; color: var(--muted); font-weight: 500;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--border); font-size: .85rem; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
.num { text-align: right; white-space: nowrap; }

input.f, select.f, textarea.f {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
  font-size: .86rem; font-family: inherit; background: var(--surface); color: var(--text);
}
input.f:focus, select.f:focus, textarea.f:focus { outline: 2px solid #cfe0f7; border-color: var(--blue); }
label.f { display: block; font-size: .76rem; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── LOGIN ── */
.login-overlay {
  position: fixed; inset: 0; background: var(--sidebar); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-box { background: var(--surface); border-radius: 16px; padding: 34px 30px; width: 100%; max-width: 360px; text-align: center; }
.login-box h1 { font-size: 1.2rem; font-weight: 900; margin-bottom: 6px; }
.login-box p { font-size: .82rem; color: var(--muted); margin-bottom: 20px; }
.login-input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: .95rem; font-family: inherit; margin-bottom: 12px; }
.login-btn { width: 100%; background: var(--orange); color: #fff; border: none; border-radius: 8px; padding: 13px; font-size: .92rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.login-err { color: var(--red); font-size: .8rem; margin-top: 10px; min-height: 18px; }

/* ── MODAL ── */
.modal { position: fixed; inset: 0; background: rgba(16, 22, 30, .55); z-index: 120; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal.show { display: flex; }
.modal-box { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1rem; font-weight: 700; }
.modal-close { margin-left: auto; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #12161c; color: #fff;
  padding: 13px 18px; border-radius: 10px; font-size: .85rem; z-index: 300;
  opacity: 0; transform: translateY(10px); transition: all .25s; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-title { font-weight: 700; margin-bottom: 2px; }

@media (max-width: 900px) {
  body.ready { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; padding: 0 14px; }
  .menu-toggle { display: block; }
  .topbar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 6px; }
  .logout-btn { padding: 8px 10px; }
  .logout-btn .logout-label { display: none; }
  .row2 { grid-template-columns: 1fr; }

  /* よく使う画面は、メニューを開かずに下のタブから行けるようにする */
  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-link {
    position: relative;
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 8px 4px 7px;
    font-size: .68rem; color: var(--muted); text-decoration: none;
  }
  .tab-link svg { width: 22px; height: 22px; }
  .tab-link.active { color: var(--orange); font-weight: 700; }
  .tab-badge {
    position: absolute; top: 3px; left: 50%; margin-left: 5px;
    background: var(--red); color: #fff;
    min-width: 17px; height: 17px; border-radius: 9px; font-size: .62rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
  }
  .tab-badge.hidden { display: none; }

  /* タブバーに隠れないよう、本文の下を空ける */
  .page { padding: 18px 14px calc(78px + env(safe-area-inset-bottom)); }
  .save-bar { margin-bottom: 8px; }
}

/* オリジナルミックスの中身（新規注文・テーブル管理で共用） */
.flavor-list { list-style: none; margin: 5px 0 0; padding: 0; font-weight: 400; font-size: .89rem; }
.flavor-list li { padding-left: 15px; position: relative; line-height: 1.6; }
.flavor-list li::before {
  content: ''; position: absolute; left: 3px; top: .62em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--orange);
}
.ob-item, .oc-item { overflow-wrap: anywhere; }
/* 中身が複数行になるので、数量と金額は上に揃える */
.ocard table.list td, .ob-items table.list td { vertical-align: top; }
