/*!
 * ShiftPay — minimalist theme (v1.4)
 * AkihiroLabs brand: navy #1E3A8A · white · charcoal text · cyan #00A8CC accent
 */

/* ═══════════ TOKENS ═══════════ */
:root {
  --bg:            #FFFFFF;
  --surface:       #F6F7F9;
  --surface-2:     #EEF0F3;
  --border:        #E6E8EC;
  --text-primary:  #1F2328;
  --text-secondary:#57606A;
  --text-muted:    #8B939E;
  --accent:        #1E3A8A;
  --accent-soft:   #EEF2FB;
  --accent-text:   #FFFFFF;
  --cyan:          #00A8CC;
  --warn:          #B7791F;
  --danger:        #CF222E;
  --success:       #1A7F37;

  /* legacy names read by charts-view.js */
  --accent-blue:   #1E3A8A;
  --accent-gold:   #1E3A8A;
  --accent-green:  #1A7F37;
  --accent-red:    #CF222E;
  --accent-purple: #6E56CF;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .08);
  --font:      'Inter', system-ui, -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --sidebar-w: 216px;
  --tabbar-h:  64px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg:            #0F1115;
  --surface:       #171A20;
  --surface-2:     #1F232B;
  --border:        #262A32;
  --text-primary:  #E6E8EB;
  --text-secondary:#A3AAB5;
  --text-muted:    #6E7682;
  --accent:        #8AA4F0;
  --accent-soft:   #1A2240;
  --accent-text:   #0F1115;
  --cyan:          #3CC8E6;
  --warn:          #E3B341;
  --danger:        #F47067;
  --success:       #57AB5A;

  --accent-blue:   #8AA4F0;
  --accent-gold:   #8AA4F0;
  --accent-green:  #57AB5A;
  --accent-red:    #F47067;

  --shadow: 0 8px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ═══════════ BASE ═══════════ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
small { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.muted { color: var(--text-secondary); }
.num, .hero-amount, .item-amount, .estimate-amount { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ═══════════ LAYOUT ═══════════ */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 24px 12px 20px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 28px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: #1E3A8A; color: #fff; font-weight: 700; font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-by { font-size: 11px; color: var(--text-muted); }
.brand-by b { color: var(--cyan); font-weight: 600; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface); color: var(--text-primary); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; padding: 0 12px; font-size: 12px; color: var(--text-muted); }

.main {
  margin-left: var(--sidebar-w);
  padding: 0 max(32px, calc((100vw - var(--sidebar-w) - 720px) / 2)) 64px;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 28px 0 20px;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ═══════════ BUTTONS ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  background: none; transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 18px; height: 18px; stroke-width: 2.2; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { opacity: .9; }
.btn-ghost { border-color: var(--border); color: var(--text-primary); background: var(--bg); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: var(--border); background: var(--bg); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 14px; }
.link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 0; background: none; color: var(--text-secondary);
}
.icon-btn:hover { background: var(--surface); color: var(--text-primary); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-spacer { width: 34px; flex-shrink: 0; }

/* ═══════════ SEGMENTED CONTROL ═══════════ */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border-radius: 10px;
}
.segmented button {
  border: 0; background: none;
  padding: 6px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
}
.segmented button.active { background: var(--bg); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
[data-theme="dark"] .segmented button.active { background: var(--surface-2); }
.segmented-sm button { padding: 4px 12px; font-size: 13px; }

/* ═══════════ HOME ═══════════ */
.hero { padding: 28px 0 24px; }
.hero-label { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.hero-amount {
  font-size: clamp(44px, 9vw, 60px); font-weight: 700;
  letter-spacing: -.035em; line-height: 1.1; margin: 6px 0 6px;
}
.hero-meta { color: var(--text-secondary); }
.hero-net { margin-top: 12px; color: var(--text-secondary); }
.hero-net strong { color: var(--text-primary); }
.hero-note { margin-top: 4px; font-size: 13px; color: var(--text-muted); }

#progressBlock { display: grid; gap: 16px; padding: 20px 0 8px; border-top: 1px solid var(--border); }
.progress-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 14px; font-weight: 500; }
.progress-top .num { color: var(--text-secondary); font-weight: 400; white-space: nowrap; margin-left: auto; }
.bar { height: 6px; margin: 8px 0 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s ease; }
.progress-foot { font-size: 13px; color: var(--text-muted); }
.progress.is-done .bar i { background: var(--success); }
.progress.is-warn .bar i { background: var(--warn); }
.progress.is-warn .progress-foot { color: var(--warn); }
.progress.is-over .bar i { background: var(--danger); }
.progress.is-over .progress-foot { color: var(--danger); font-weight: 600; }

/* ═══════════ BLOCKS / LISTS ═══════════ */
.block { padding: 24px 0; border-top: 1px solid var(--border); }
.view > .block:first-child { border-top: 0; padding-top: 4px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.block h2, .block-title { font-size: 16px; font-weight: 600; }
.block-title { margin-bottom: 8px; }
.block-hint { font-size: 13px; color: var(--text-muted); margin: -2px 0 12px; }
.sub-head { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 16px 0 4px; }

.list { display: flex; flex-direction: column; }
.list-empty { color: var(--text-muted); font-size: 14px; padding: 12px 0; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 8px; margin: 0 -8px; width: calc(100% + 16px);
  border: 0; border-radius: var(--radius-sm);
  background: none; text-align: left;
}
button.item:hover { background-color: var(--surface); }
.item + .item {
  background-image: linear-gradient(var(--border), var(--border));
  background-size: calc(100% - 16px) 1px; background-position: 8px 0; background-repeat: no-repeat;
}
button.item:hover, button.item:hover + .item { background-image: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-title { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-sub { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-amount { font-weight: 600; white-space: nowrap; }
.item-amount small { margin-left: 1px; }
.item-actions { display: flex; align-items: center; gap: 6px; }
.tag {
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 6px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-secondary);
}
.tag-accent { background: var(--accent-soft); color: var(--accent); }

/* Fold (details) */
.fold summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 600;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary svg { color: var(--text-muted); transition: transform .2s; }
.fold[open] summary svg { transform: rotate(180deg); }
.fold-body { padding-top: 4px; }
.chart-wrap { position: relative; height: 200px; margin-top: 8px; }

/* Empty state */
.empty { text-align: center; padding: 64px 16px; }
.empty-mascot { font-size: 48px; line-height: 1; margin-bottom: 16px; }
.empty h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.empty p { color: var(--text-secondary); max-width: 320px; margin: 0 auto 20px; }
.empty-sm { padding: 16px 0; text-align: left; }
.empty-sm p { margin: 0 0 12px; max-width: none; }

/* ═══════════ SETTINGS ═══════════ */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 0;
}
.row + .row { border-top: 1px solid var(--border); }
.row-wrap { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
.row-label { display: flex; flex-direction: column; font-weight: 500; }
.row-label small { margin-top: 1px; }
.row-actions { display: flex; gap: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 8px; }
.chip {
  border: 1px solid var(--border); background: var(--bg);
  padding: 4px 12px; border-radius: 99px;
  font-size: 13px; color: var(--text-secondary);
}
.chip:hover { background: var(--surface); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.tax-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.tax-item + .tax-item { border-top: 1px solid var(--border); }
.tax-name { flex: 1; min-width: 0; }
.tax-name small { margin-left: 4px; }
#taxItemsList.is-off .tax-item { opacity: .45; }
.tax-add { display: flex; gap: 8px; align-items: center; padding-top: 12px; }
.tax-add > .input { flex: 1; min-width: 0; }
.tax-total { text-align: right; font-weight: 600; padding-top: 12px; font-variant-numeric: tabular-nums; }
.tax-total:empty { display: none; }
.about { text-align: center; color: var(--text-muted); font-size: 13px; padding: 24px 0 8px; }

/* ═══════════ FORMS ═══════════ */
.input {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-primary);
  outline: none; transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
select.input { padding-right: 32px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B939E' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled { opacity: .6; }
.input-w { width: 180px; }
.input-xs { height: 34px; width: 110px; padding: 0 10px; font-size: 14px; }
.input-color { padding: 4px; width: 56px; cursor: pointer; }
.input-yen { position: relative; display: inline-flex; align-items: center; }
.input-yen::before { content: '¥'; position: absolute; left: 11px; color: var(--text-muted); font-size: 14px; pointer-events: none; }
.input-yen .input { padding-left: 24px; }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.field .input { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-color { flex: 0; }
.field-color .input { width: 56px; }
.hint { font-size: 12px; color: var(--text-muted); }
.hint:empty { display: none; }

.check-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* Switch */
.switch { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; z-index: 1; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: inherit; }
.switch-track {
  width: 40px; height: 24px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border);
  position: relative; transition: background .2s, border-color .2s;
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .2s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:disabled + .switch-track { opacity: .5; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-sm .switch-track { width: 34px; height: 20px; }
.switch-sm .switch-track::after { width: 14px; height: 14px; }
.switch-sm input:checked + .switch-track::after { transform: translateX(14px); }

/* Day picker */
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-picker label { cursor: pointer; }
.day-picker input { position: absolute; opacity: 0; pointer-events: none; }
.day-picker span {
  display: grid; place-items: center; width: 44px; height: 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.day-picker input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.day-picker input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* "More options" disclosure */
.more { border-top: 1px solid var(--border); padding-top: 12px; }
.more summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--accent); list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ' +'; }
.more[open] summary::after { content: ' −'; }
.more-body { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; }

/* Rate blocks (job modal) */
.rate-block { display: flex; flex-direction: column; gap: 8px; }
.rate-head { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
.rate-badge { margin-left: auto; font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rate-badge.badge-off { color: var(--text-muted); }
.rate-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rate-input { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 14px; }
.rate-input .input { width: 96px; height: 34px; }

/* Shift estimate */
.estimate {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.estimate > div { display: flex; flex-direction: column; }
.estimate-label { font-size: 13px; font-weight: 600; color: var(--accent); }
.estimate-sub { font-size: 12px; color: var(--text-secondary); }
.estimate-amount { font-size: 24px; font-weight: 700; color: var(--accent); letter-spacing: -.02em; }

/* ═══════════ MODALS ═══════════ */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 17, 21, .4);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; z-index: 100; left: 50%; top: 50%;
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 16px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -48%) scale(.98); transition: opacity .2s, transform .2s;
}
.modal.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal-sm { width: min(400px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 4px 24px; }
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 16px 24px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 24px 20px; }
.spacer { flex: 1; }

/* ═══════════ TOASTS ═══════════ */
.toasts {
  position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 99px;
  background: var(--text-primary); color: var(--bg);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-icon svg { width: 16px; height: 16px; }
.toast-success .toast-icon { color: #4ADE80; }
.toast-error   .toast-icon { color: #F87171; }
.toast-info    .toast-icon { color: #7DD3FC; }

/* ═══════════ CALENDAR ═══════════ */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-title { font-size: 18px; font-weight: 600; min-width: 150px; text-align: center; }
.cal-nav .btn { margin-left: 8px; }
.cal-stats { color: var(--text-secondary); font-size: 14px; padding: 12px 0 16px; font-variant-numeric: tabular-nums; }

#fullcalendar {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--bg);
  --fc-neutral-bg-color: var(--surface);
  --fc-today-bg-color: var(--accent-soft);
  --fc-list-event-hover-bg-color: var(--surface);
  --fc-event-border-color: transparent;
  font-size: 13px;
}
#fullcalendar .fc-scrollgrid { border-radius: var(--radius); overflow: hidden; }
#fullcalendar .fc-col-header-cell { padding: 8px 0; font-weight: 500; color: var(--text-muted); font-size: 12px; }
#fullcalendar .fc-col-header-cell-cushion,
#fullcalendar .fc-daygrid-day-number { color: inherit; text-decoration: none; }
#fullcalendar .fc-daygrid-day-number { font-size: 12px; color: var(--text-secondary); padding: 6px 8px; }
#fullcalendar .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 700; }
#fullcalendar .fc-day-sun .fc-daygrid-day-number,
#fullcalendar .fc-day-holiday .fc-daygrid-day-number { color: var(--danger); }
#fullcalendar .fc-day-sat .fc-daygrid-day-number { color: var(--accent); }
#fullcalendar .fc-daygrid-day { cursor: pointer; }
#fullcalendar .fc-daygrid-day:hover { background: var(--surface); }
#fullcalendar .fc-daygrid-day-frame { min-height: 84px; }
#fullcalendar .fc-daygrid-event {
  border-radius: 5px; padding: 1px 5px; margin: 1px 4px 2px;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
#fullcalendar .fc-event-title { overflow: hidden; text-overflow: ellipsis; }
#fullcalendar .ev { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
#fullcalendar .fc-daygrid-more-link { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.fc-holiday-name {
  font-size: 10px; color: var(--danger); padding: 0 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8;
}
#fullcalendar .fc-list { border-radius: var(--radius); overflow: hidden; }
#fullcalendar .fc-list-day-cushion { background: var(--surface); }
#fullcalendar .fc-list-day-cushion a { color: var(--text-primary); text-decoration: none; font-weight: 600; }
#fullcalendar .fc-list-event { cursor: pointer; }
#fullcalendar .fc-list-empty { background: var(--bg); color: var(--text-muted); }
#fullcalendar .fc-popover { background: var(--bg); border-color: var(--border); box-shadow: var(--shadow); border-radius: var(--radius-sm); }
#fullcalendar .fc-popover-header { background: var(--surface); }

/* ═══════════ MOBILE TAB BAR ═══════════ */
.tabbar { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .main { margin: 0; max-width: none; padding: 0 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .topbar { padding: 20px 0 12px; }
  .topbar-add { display: none; }
  .page-title { font-size: 20px; }

  .tabbar {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; font-weight: 500; color: var(--text-muted); text-decoration: none;
  }
  .tab.active { color: var(--accent); }
  .tab-add {
    justify-self: center; width: 48px; height: 48px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--accent); color: var(--accent-text);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  .tab-add svg { width: 24px; height: 24px; stroke-width: 2.2; }

  .toasts { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }

  /* bottom-sheet modals */
  .modal {
    left: 0; right: 0; top: auto; bottom: 0;
    width: 100%; max-height: 92vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal.active { transform: none; }
  .modal-sm { width: 100%; }

  .cal-title { min-width: 0; font-size: 16px; }
  #fullcalendar .fc-daygrid-day-frame { min-height: 64px; }
  #fullcalendar .fc-daygrid-event { font-size: 10px; padding: 0 3px; margin: 1px 2px; }
  .fc-holiday-name { display: none; }

  .row { align-items: flex-start; flex-direction: column; gap: 8px; }
  .row-wrap { flex-direction: row; }
  .row .input-w, .row .input-yen { width: 100%; }
  .row .input-yen .input { width: 100%; }
  .row .switch { align-self: flex-start; }
  label.row:has(.switch) { flex-direction: row; align-items: center; }
  .item-tpl { flex-wrap: wrap; }
  .item-tpl .item-actions { width: 100%; padding-left: 22px; }
}

@media (max-width: 600px) {
  .tax-name small { display: none; }
}

@media (max-width: 420px) {
  .field-row-3 { grid-template-columns: 1fr 1fr; }
  .field-row-3 .field:last-child { grid-column: span 2; }
  .tax-item .input-xs { width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ═══════════ LATE NIGHT (v1.4) ═══════════ */
.late-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.late-manual { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); }
.late-manual .input { width: 88px; }
.hint { font-size: 12px; color: var(--text-muted); }

/* ═══════════ DISCORD AD (AkihiroLabs) ═══════════ */
.discord-ad {
  display: flex; align-items: center; gap: 14px;
  margin-top: 24px; padding: 16px;
  background: var(--accent); color: #fff;
  border-radius: var(--radius); text-decoration: none;
}
.discord-ad:hover { opacity: .95; }
.discord-ad-emoji { font-size: 28px; line-height: 1; }
.discord-ad-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.discord-ad-text strong { font-size: 15px; }
.discord-ad-text small { font-size: 13px; color: rgba(255,255,255,.85); }
.discord-ad-btn { background: var(--cyan); color: #fff; flex-shrink: 0; }
.discord-mini {
  display: block; margin: auto 12px 8px; padding: 8px 10px;
  font-size: 13px; font-weight: 500; text-decoration: none;
  color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm);
}
.discord-mini + .side-foot { margin-top: 0; }
[data-theme="dark"] .discord-mini { color: #fff; background: var(--surface-2); }
[data-theme="dark"] .discord-ad { background: #1E3A8A; }

/* PWA install row — hidden until the browser offers install */
[data-install][hidden] { display: none !important; }
