.wrap { max-width: 1040px; margin: 0 auto; padding: 0 32px; }

.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.bar { height: 68px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; flex: none; margin-right: auto; }
.brand small { font-size: 13px; font-weight: 600; color: var(--text-3); padding-top: 2px; }
.right { display: flex; align-items: center; gap: 6px; flex: none; }
.timer {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.timer.soon { background: var(--red-soft); color: var(--red); }
.user { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 4px; border-radius: 22px; background: var(--surface); }
.avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex: none; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user strong { font-size: 14px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { height: 32px; padding: 0 12px; border-radius: 16px; font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--surface-2); transition: background .15s; }
.logout:hover { background: var(--hover); color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; height: 48px; padding: 0 14px; font-size: 16px; font-weight: 600; color: var(--text-3); transition: color .15s;
}
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; border-radius: 3px; background: var(--text); }

.content { padding-top: 24px; padding-bottom: 64px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper strong { min-width: 64px; text-align: center; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stepper .icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.tools { display: flex; align-items: center; gap: 8px; }
.chip {
  height: 36px; padding: 0 12px; border-radius: 10px; background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; transition: background .15s;
}
.chip:hover { background: var(--hover); color: var(--text); }
.ghost {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px;
  background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600; transition: background .15s, color .15s;
}
.ghost:hover { background: var(--blue-soft); color: var(--blue); }
.btn-add {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 11px; border-radius: 10px;
  background: var(--blue); color: #fff; font-size: 14px; font-weight: 600; transition: filter .15s, transform .15s;
}
.btn-add:hover { filter: brightness(.94); }
.btn-add:active { transform: scale(.97); }

.panel { background: var(--surface); border-radius: 24px; }
.panel + .panel, .notice-bar + .panel, .panel + .notice-bar, .stats + .panel { margin-top: 12px; }

.chart-panel { padding: 26px 26px 18px; }
.hero { display: flex; flex-direction: column; gap: 4px; }
.hero-label { font-size: 15px; font-weight: 600; color: var(--text-2); }
.hero-value { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 14px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; min-height: 20px; }

.chart { margin-top: 18px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; height: 196px; }
.bar-col {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  height: 100%; border-radius: 12px; padding: 0 0 4px; transition: background .15s;
}
.bar-col:hover:not(:disabled) { background: var(--hover); }
.bar-col:disabled { cursor: default; }
.bar-track { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-top: 22px; }
.bar-fill {
  width: min(28px, 62%); min-height: 2px; border-radius: 6px 6px 2px 2px; background: color-mix(in srgb, var(--blue) 32%, transparent);
  transition: background .15s, height .3s cubic-bezier(.2, .8, .2, 1);
}
.bar-col:hover .bar-fill { background: color-mix(in srgb, var(--blue) 50%, transparent); }
.bar-col[aria-pressed="true"] .bar-fill { background: var(--blue); }
.bar-value { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-label { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.bar-col[aria-pressed="true"] .bar-label { color: var(--text); }
.bar-col:disabled .bar-label { color: var(--text-4); }
.bar-col:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }

.tooltip {
  position: fixed; z-index: 40; pointer-events: none; padding: 8px 11px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
}
.tooltip span { display: block; font-weight: 500; opacity: .7; font-size: 12px; }

.notice-bar { padding: 14px 18px; border-radius: 16px; background: var(--red-soft); color: var(--red); font-size: 14px; font-weight: 600; }

.list { padding: 8px; }
.row {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; text-align: left;
  transition: background .15s;
}
button.row:hover { background: var(--hover); }
.row:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.vico {
  width: 44px; height: 44px; border-radius: 13px; background: var(--icon-tile); border: 1px solid var(--line);
  display: grid; place-items: center; flex: none;
}
.vico img { width: 24px; height: 24px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-name { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.row-item { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; font-variant-numeric: tabular-nums; }
.row-amount strong { font-size: 16px; font-weight: 700; }
.row-amount span { font-size: 13px; color: var(--text-3); }
.row .chev { color: var(--text-4); transition: transform .2s; flex: none; }
.row[aria-expanded="true"] .chev { transform: rotate(180deg); }
.tag { height: 20px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; letter-spacing: 0; }
.tag.auto { background: var(--green-soft); color: var(--green); }
.tag.est { background: var(--surface-2); color: var(--text-3); border: 1px dashed var(--text-4); }
.tag.cycle { background: var(--blue-soft); color: var(--blue); }
.row.est .row-amount strong { color: var(--text-2); }

.services { margin: 0 14px 10px 72px; padding: 6px 0 4px; border-top: 1px solid var(--line); }
.svc { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.svc-amt { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.svc-amt small { font-size: 13px; color: var(--text-3); }
.svc-amt b { min-width: 96px; text-align: right; color: var(--text); font-weight: 600; }
.svc-tools { display: flex; gap: 8px; padding-top: 8px; }
.svc-tools .ghost { background: var(--surface-2); }

.empty { padding: 56px 16px; text-align: center; color: var(--text-3); font-size: 15px; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border-radius: 20px; padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.stat span { font-size: 14px; font-weight: 600; color: var(--text-3); }
.stat strong { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat small { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; padding: 6px 8px; }
.matrix { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 13px; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 11px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.matrix th { font-weight: 600; color: var(--text-3); }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.matrix td:first-child { font-weight: 700; font-size: 14px; }
.matrix td:first-child .cell-vendor { display: flex; align-items: center; gap: 8px; }
.matrix td:first-child img { width: 24px; height: 24px; padding: 4px; border-radius: 7px; background: var(--icon-tile); }
.matrix td.zero { color: var(--text-4); }
.matrix td.est { color: var(--text-3); font-style: italic; }
.matrix tr:last-child td { border-bottom: 0; font-weight: 700; color: var(--text); }
.matrix td:last-child, .matrix th:last-child { font-weight: 700; color: var(--text); }
.matrix tbody tr:hover td { background: var(--surface-2); }

body:has(dialog[open]) { overflow: hidden; }
.sheet {
  position: fixed; inset: 0; width: min(480px, calc(100% - 24px)); margin: auto;
  max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 24px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgba(8, 13, 24, .22);
}
.sheet.small { width: min(360px, calc(100% - 24px)); }
.sheet::backdrop { background: rgba(8, 13, 24, .56); }
.sheet-panel { display: grid; gap: 16px; padding: 20px; }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -.025em; margin-right: auto; padding-left: 2px; }
.sheet-head .ghost { height: 32px; background: var(--surface-2); }
.vendors { border: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.vendors legend, .field > span { font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 8px; padding-left: 2px; }
.vendor-opt { position: relative; cursor: pointer; }
.vendor-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.vendor-opt span {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 9px 4px 8px; border-radius: 14px;
  border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text-2); text-align: center; line-height: 1.2;
  transition: border-color .15s, background .15s;
}
.vendor-opt img { width: 32px; height: 32px; padding: 6px; border-radius: 9px; background: var(--icon-tile); }
.vendor-opt:hover span { background: var(--hover); }
.vendor-opt input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: var(--text); }
.vendor-opt input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 1px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field input, .field select {
  height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 15px; color: var(--text); outline: 0; width: 100%; transition: border-color .15s;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 15px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:focus, .field select:focus { border-color: var(--blue); }
.field input::placeholder { color: var(--text-4); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amount { display: flex; gap: 8px; align-items: center; }
.amount input { flex: 1; font-variant-numeric: tabular-nums; }
.amount .unit { font-size: 15px; color: var(--text-2); padding-right: 6px; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); height: 46px; flex: none; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.seg button { padding: 0 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-3); transition: background .15s, color .15s; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(2, 32, 71, .12); }
[data-theme="dark"] .seg button[aria-checked="true"] { background: var(--press); box-shadow: none; }
.form-error { color: var(--red); font-size: 14px; font-weight: 600; }
.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }
.sheet-actions .btn-primary { height: 50px; border-radius: 14px; font-size: 16px; }
.btn-danger { flex: none; height: 50px; padding: 0 18px; border-radius: 14px; background: var(--red-soft); color: var(--red); font-size: 16px; font-weight: 600; }
.btn-danger:hover { filter: brightness(.96); }

.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 50; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.icon-btn:focus-visible, .chip:focus-visible, .ghost:focus-visible, .btn-add:focus-visible, .tab:focus-visible, .seg button:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}

@media (max-width: 860px) {
  .wrap { padding: 0 16px; }
  .user strong { display: none; }
  .content { padding-top: 16px; }
  .chart-panel { padding: 20px 14px 14px; }
  .hero { padding: 0 6px; }
  .hero-value { font-size: 28px; }
  .chart { gap: 2px; height: 172px; }
  .bar-value { font-size: 10px; }
  .bar-label { font-size: 11px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .stat { flex-direction: row; align-items: baseline; justify-content: space-between; padding: 16px 18px; }
  .stat strong { font-size: 19px; }
  .stat small { display: none; }
}
@media (max-width: 520px) {
  .timer { display: none; }
  .right { gap: 2px; }
  .toolbar { gap: 8px; }
  .tools { width: 100%; }
  .tools .btn-add { margin-left: auto; }
  .row { gap: 10px; padding: 11px 8px; }
  .vico { width: 38px; height: 38px; border-radius: 11px; }
  .vico img { width: 20px; height: 20px; }
  .services { margin-left: 56px; margin-right: 8px; }
  .vendors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
