/* Bancada app. Layout: a jeweler's bench sheet. Inputs on the left,
   a hanging price tag on the right, the piece library below. */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Header */
.top { padding-block: 24px 20px; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.brand { display: grid; gap: 2px; color: inherit; text-decoration: none; }
.brand-name { font-family: var(--display); font-size: 40px; line-height: 1; letter-spacing: -0.01em; }
.brand-tag { color: var(--muted); font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.account { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.account-email { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

/* Sign in */
.signin {
  background: var(--surface); border: 1px solid var(--patina); border-radius: 12px;
  padding: 18px 20px; display: grid; gap: 12px; margin-bottom: 20px;
}
.signin h2 { font-family: var(--display); font-weight: 400; font-size: 26px; }
.signin-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.signin-form .f { flex: 1 1 260px; }
#signin-msg.ok { color: var(--patina); font-weight: 600; }
#signin-msg.bad { color: var(--under); font-weight: 600; }

/* Form fields */
.f { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0; }
.f .hint { font-weight: 400; font-size: 12px; }
.in { position: relative; display: block; }
.in input { padding-right: 34px; }
.in i {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--muted); pointer-events: none;
}
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }

/* Metal rates + settings */
.rates {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; display: grid; gap: 14px; margin-bottom: 24px;
}
.rates-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rates-actions { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rates-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; align-items: end; }
.rates-note { font-size: 13px; color: var(--muted); display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; padding: 0; accent-color: var(--patina); }
#prices-msg.bad { color: var(--under); font-weight: 600; }
details.settings { border-top: 1px solid var(--line); padding-top: 12px; }
details.settings summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.settings summary::-webkit-details-marker { display: none; }
details.settings summary::before { content: "+"; font-family: var(--mono); color: var(--muted); width: 12px; }
details.settings[open] summary::before { content: "−"; }
.settings-body { display: grid; gap: 18px; padding-top: 16px; }
.settings-body h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.fees { display: grid; gap: 8px; }
.fee-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 96px; gap: 10px; align-items: center; font-size: 14px; }
.fee-head { font-size: 12px; color: var(--muted); }

/* Main grid */
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
@media (max-width: 920px) { .main-grid { grid-template-columns: minmax(0, 1fr); } }

.calc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 22px 22px; min-width: 0; }
.blk { display: grid; gap: 12px; padding-block: 20px; border-top: 1px solid var(--line); min-width: 0; }
.blk:first-child { border-top: 0; }
.blk-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.blk h3 { font-size: 15px; font-weight: 700; }
.piece-head { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.piece-head .f { flex: 1 1 240px; }
.piece-head input { font-family: var(--display); font-size: 24px; padding: 6px 10px; }
.metal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.metal-row .stamp { margin-bottom: 9px; font-size: 13px; }
.calcline { font-family: var(--mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.xhead, .xrow { display: grid; grid-template-columns: minmax(0, 1fr) 70px 92px 34px; gap: 8px; align-items: center; }
.xhead { font-size: 12px; color: var(--muted); }
.xlist { display: grid; gap: 8px; }
.icon-btn {
  font: inherit; font-size: 18px; line-height: 1; width: 34px; height: 38px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--under); border-color: var(--under); }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.save-msg { font-size: 13px; color: var(--patina); font-weight: 600; }
.save-msg.bad { color: var(--under); }

/* Result: the price tag */
.result { position: sticky; top: 16px; display: grid; gap: 22px; min-width: 0; }
@media (max-width: 920px) { .result { position: static; } }
.tag {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px 16px 16px 6px; padding: 22px 22px 20px 40px; display: grid; gap: 14px;
}
.tag::before {
  content: ""; position: absolute; left: 14px; top: 28px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
}
.tag-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price { font-family: var(--display); font-size: clamp(46px, 7vw, 64px); line-height: 0.95; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.price-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; font-variant-numeric: tabular-nums; border-top: 1px dashed var(--line); padding-top: 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.compare { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.compare:empty { display: none; }

.sec h3 { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--sunken); gap: 2px; }
.bar span { display: block; height: 100%; transition: width 0.25s ease; }
.legend { display: grid; gap: 5px; margin-top: 12px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.legend div { display: grid; grid-template-columns: 12px 1fr auto 44px; gap: 8px; align-items: center; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend .v { font-weight: 600; text-align: right; }
.legend .p { color: var(--muted); text-align: right; font-size: 12.5px; }

/* Relative so the visually hidden header label stays inside the scroll box. */
.tbl-wrap { overflow-x: auto; position: relative; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 500; font-family: var(--mono); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.neg { color: var(--under); font-weight: 700; }
.metals tr.current td { font-weight: 700; background: var(--sunken); }
.metals tr.current td:last-child { color: var(--ink); }
.sec .note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* Library */
.library { margin-top: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 14px; }
.lib-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.library h2 { font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1.1; }
.library .intro { color: var(--muted); max-width: 60ch; margin-top: 4px; }
.lib-store { display: grid; justify-items: end; gap: 2px; }
.store-status { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.store-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--patina); flex: none; }
.store-status.warn::before { background: var(--gold); }
.store-status.bad::before { background: var(--under); }
.summary { font-weight: 600; }
.summary.bad { color: var(--under); }
.summary:empty { display: none; }
.lib-name { font-weight: 600; }
.lib-name .badge { margin-left: 8px; vertical-align: 2px; }
.drift { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 12px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.lib-data { display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center; }
.lib-data:not(:has(button:not([hidden]))) { display: none; }
.delete-confirm { background: var(--under-soft); border-radius: 10px; padding: 14px 16px; display: grid; gap: 10px; }
.delete-confirm p { max-width: 70ch; }
.btn.danger { background: var(--under); border-color: var(--under); color: var(--bg); }
#delete-msg:empty { display: none; }
#delete-msg.ok { color: var(--patina); font-weight: 600; }
#delete-msg.bad { color: var(--under); font-weight: 600; }
.ex-note { background: var(--gold-soft); color: var(--ink); padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }

/* Feedback dialog */
.feedback {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  padding: 22px; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
}
.feedback::backdrop { background: rgba(0, 0, 0, 0.45); }
.feedback form { display: grid; gap: 14px; }
.feedback h2 { font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1.1; }
.feedback textarea {
  font: inherit; font-size: 15px; width: 100%; min-height: 120px; resize: vertical;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.feedback textarea:focus-visible { outline: 2px solid var(--patina); outline-offset: 1px; }
.fb-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#fb-msg:empty { display: none; }
#fb-msg.ok { color: var(--patina); font-weight: 600; }
#fb-msg.bad { color: var(--under); font-weight: 600; }

.app-foot { margin-top: 28px; font-size: 12.5px; color: var(--muted); display: grid; gap: 6px; max-width: 80ch; }

@media (max-width: 600px) {
  .lib-store { justify-items: start; }
}
@media (max-width: 480px) {
  .brand-name { font-size: 34px; }
  .calc { padding: 2px 14px 16px; }
  .library { padding: 16px; }
  .tag { padding-right: 16px; }
  .xhead, .xrow { grid-template-columns: minmax(0, 1fr) 54px 76px 34px; gap: 6px; }
  .fee-row { grid-template-columns: minmax(0, 1fr) 76px 76px; }
}
