/* ---- chamfered surfaces: a 1px hairline frame made of two clipped layers ---- */

.panel, .tile, .sheet {
  position: relative;
  padding: 18px 20px 20px;
  background: var(--line);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.panel::before, .tile::before, .sheet::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--panel);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.panel > *, .tile > *, .sheet > * { position: relative; }

.panel-head, .sheet-head, .tile-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2, .sheet-head h2 { color: var(--text); }
.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 13px; }

/* HUD corner brackets on the two square corners. */
.brackets::after {
  content: "";
  position: absolute;
  inset: 7px;
  pointer-events: none;
  opacity: .75;
  background:
    linear-gradient(var(--accent), var(--accent)) top right / 16px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top right / 1px 16px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom left / 16px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom left / 1px 16px no-repeat;
}

/* ---- buttons ---- */

.btn {
  --cut: 6px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font: 500 12px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text);
  background: var(--line-hi);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: color .15s, transform .12s var(--ease);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  background: var(--raised);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: background-color .15s;
}
.btn { isolation: isolate; }
.btn:hover::before { background: #20242f; }
.btn:hover { color: var(--accent); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 6px 11px; font-size: 11px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost::before { background: transparent; }
.btn.ghost:hover::before { background: rgb(230 232 240 / .05); }
.btn.danger-text:hover, .btn.danger { color: var(--pink); }
.btn.danger { background: var(--pink); }
.btn.confirm { color: var(--accent); background: rgb(159 216 203 / .55); }

/* The primary button is cut with gradients instead of clip-path so its glow is not clipped away. */
.btn.primary {
  clip-path: none;
  color: #0b0c11;
  background:
    linear-gradient(135deg, transparent 5px, var(--accent) 5.5px) left / 51% 100% no-repeat,
    linear-gradient(-45deg, transparent 5px, var(--accent) 5.5px) right / 51% 100% no-repeat;
  filter: drop-shadow(0 0 9px rgb(159 216 203 / .32));
}
.btn.primary::before { display: none; }
.btn.primary:hover { color: #0b0c11; filter: drop-shadow(0 0 13px rgb(159 216 203 / .55)); }
.btn.primary b { font-size: 15px; line-height: 1; }

.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); font-size: 18px; line-height: 1; transition: color .15s, background-color .15s; }
.icon-btn:hover { color: var(--accent); background: rgb(230 232 240 / .05); }

.link { color: var(--accent); font-size: 13px; }
.link:hover { text-shadow: 0 0 12px rgb(159 216 203 / .5); }
.link.more { display: inline-block; margin-top: 12px; font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; }

/* ---- chips, tags, dots ---- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px;
  border: 1px solid var(--line-hi);
  font: 500 10.5px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
}
.chip-dot { width: 6px; height: 6px; background: currentColor; }
.chip.ok { color: var(--sage); border-color: rgb(184 207 160 / .4); }
.chip.warn { color: var(--peach); border-color: rgb(232 184 154 / .4); }
.chip.over, .chip.error { color: var(--pink); border-color: rgb(227 179 200 / .45); }
.chip.sync.saving { color: var(--lavender); }
.chip.sync.saving .chip-dot { animation: pulse .9s ease-in-out infinite; }
.chip.sync.idle .chip-dot { background: var(--sage); box-shadow: 0 0 8px rgb(184 207 160 / .7); }

.tag { margin-left: 8px; padding: 1px 6px; border: 1px solid var(--line-hi); font: normal 500 10px var(--mono); letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.tag.warn { color: var(--peach); border-color: rgb(232 184 154 / .4); }

.dot { flex: none; display: inline-block; width: 9px; height: 10px; background: var(--dot, var(--dim)); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.dot.dim { background: var(--dim); }
.dot.income { background: var(--income); }
.dot.expense { background: var(--expense); }
.label .dot { margin-right: 8px; vertical-align: -1px; }

/* ---- rows ---- */

.rows { display: grid; }
.row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 8px;
  border-top: 1px solid rgb(38 42 56 / .7);
  transition: background-color .12s;
}
.rows > .row:first-child { border-top: 0; }
button.row:hover, .row-open:hover .row-title { background-color: rgb(230 232 240 / .035); }
button.row:hover .row-title, .row-open:hover .row-title { color: var(--accent); }
.row-date { width: 42px; color: var(--muted); font-size: 12px; }
.row-main { min-width: 0; display: grid; text-align: left; overflow: hidden; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .12s; }
.row-sub { display: flex; align-items: center; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; }
.row-sub:empty { display: none; }
.row-amount { display: grid; justify-items: end; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.tx-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.tx-row > .dot:first-child { margin-left: 2px; }
.recurring-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.category-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.category-row.archived { opacity: .55; }
.due-row.done .row-title, .due-row.skipped .row-title { color: var(--muted); }
.due-row.skipped .row-amount { text-decoration: line-through; opacity: .6; }
.due-row.overdue .row-date { color: var(--peach); }

.day-group + .day-group { margin-top: 14px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 8px; background: var(--inset); border-left: 2px solid var(--line-hi); font-size: 13px; }

.empty { display: grid; justify-items: start; gap: 12px; padding: 14px 8px 6px; color: var(--muted); }
.note { margin-top: 14px; font-size: 12.5px; max-width: 78ch; }

/* ---- segmented progress ---- */

.seg { position: relative; display: flex; height: 8px; background: var(--inset); overflow: hidden; --tone: var(--mint); }
.seg::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 10px, var(--panel) 10px 12px); }
.seg.warn { --tone: var(--peach); }
.seg.over { --tone: var(--pink); }
.seg-fill { height: 100%; background: var(--tone); }
.seg-pending { height: 100%; opacity: .75; background: repeating-linear-gradient(135deg, var(--tone) 0 2px, transparent 2px 5px); }

/* ---- forms ---- */

input:not([type=file]), select {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-hi);
  border-radius: 0;
  background: var(--inset);
  outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--dim); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(159 216 203 / .12), 0 0 18px rgb(159 216 203 / .12); }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%); background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat; }

.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.field { display: grid; gap: 6px; min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.form-actions > :first-child:not(:only-child) { margin-right: auto; }
.form-error { color: var(--pink); font-size: 13px; }
.form-error.glitch { animation: glitch .22s steps(2) 1; }
.button-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-hi); }
.segmented-item { padding: 8px 12px; text-align: center; font: 500 11.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); transition: color .15s, background-color .15s; }
.segmented-item + .segmented-item { border-left: 1px solid var(--line-hi); }
.segmented-item[aria-pressed=true] { color: var(--accent); background: rgb(159 216 203 / .1); text-shadow: 0 0 12px rgb(159 216 203 / .4); }

.amount { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; }
.amount-input, .amount .currency-select { height: 56px; }
.amount-input { padding: 12px 14px; font-size: 26px; }
.currency-select { font-family: var(--mono); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-option { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line-hi); font-size: 13px; color: var(--muted); transition: color .12s, border-color .12s, background-color .12s; }
.chip-option:hover { color: var(--text); }
.chip-option[aria-checked=true] { color: var(--text); border-color: var(--dot); background: color-mix(in srgb, var(--dot) 12%, transparent); box-shadow: 0 0 14px color-mix(in srgb, var(--dot) 22%, transparent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 30px; height: 30px; border: 1px solid var(--line-hi); display: grid; place-items: center; }
.swatch::after { content: ""; width: 14px; height: 16px; background: var(--dot); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.swatch[aria-pressed=true] { border-color: var(--dot); box-shadow: 0 0 12px color-mix(in srgb, var(--dot) 40%, transparent); }

/* ---- sheet ---- */

@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes scrim-in { from { opacity: 0; } }

.scrim { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgb(6 7 10 / .78); overflow-y: auto; animation: scrim-in .15s; }
.sheet { width: min(560px, 100%); padding: 18px 20px 20px; animation: sheet-in .2s var(--ease); }
.sheet-head .code { margin-left: auto; }
.sheet-text { color: var(--muted); margin-bottom: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 30;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 24px);
  padding: 10px 16px;
  border: 1px solid var(--line-hi);
  border-left: 2px solid var(--accent);
  background: var(--raised);
  box-shadow: 0 10px 30px rgb(0 0 0 / .5);
  font-size: 13px;
  animation: sheet-in .2s var(--ease);
}

.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  display: grid;
  gap: 1px;
  padding: 7px 10px;
  border: 1px solid var(--line-hi);
  background: var(--raised);
  box-shadow: 0 8px 24px rgb(0 0 0 / .5);
  font: 500 11.5px var(--mono);
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}
.tip b { color: var(--text); font-weight: 500; }

@media (max-width: 860px) {
  /* `safe` keeps a sheet taller than the screen reachable by scrolling the scrim. */
  .scrim { place-items: safe end center; padding: 0; }
  .sheet { width: 100%; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .due-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .due-row .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  input:not([type=file]), select { font-size: 16px; }
  .amount-input { font-size: 26px; }
}
