/* =========================================================
   Accounts, orders & admin · builds on styles.css tokens
   ========================================================= */

/* ---------- Shared bits ---------- */
.demo-banner {
  background: var(--gold); color: var(--ink); text-align: center;
  font-size: .9rem; padding: 8px 16px; line-height: 1.4;
}
.demo-banner code { font-size: .85em; background: rgb(14 13 11 / .1); padding: 1px 6px; border-radius: 4px; }

.link-btn {
  background: none; border: 0; padding: 0 2px; min-height: 32px;
  color: var(--gold-hi); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn:hover { color: var(--gold); }
.light .link-btn, .panel .link-btn { color: var(--gold-deep); }

.btn-ghost-light { --bg: transparent; --fg: var(--text-on-dark); --bd: #5a5448; margin-top: 12px; }
.btn-ghost-light:hover { --bd: var(--gold); --fg: var(--gold-hi); }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.notice-error { border-color: var(--danger-on-dark) !important; background: rgb(255 154 143 / .08) !important; }
.notice-error strong { color: var(--danger-on-dark) !important; }

/* ---------- Order form: account ---------- */
.acct-box { border: 1px solid var(--ink-3); background: var(--ink); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: var(--s-3); color: var(--muted-on-dark); }
.acct-box strong { color: var(--text-on-dark); }
#acct-signed-out { margin-bottom: var(--s-3); }
#acct-signed-out .field-help a { color: var(--gold-hi); font-weight: 600; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--ink); border: 1px solid #4a453b; border-radius: 999px; margin-bottom: 10px; }
.segmented label { position: relative; display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 12px;
  border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--muted-on-dark); text-align: center;
  transition: background-color var(--dur), color var(--dur);
}
.segmented input:checked + span { background: var(--gold); color: var(--ink); }
.segmented input:focus-visible + span { outline: 3px solid var(--gold-hi); outline-offset: 2px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 76px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 38px; min-width: 60px; padding: 0 10px; border: 0; border-radius: 8px;
  background: var(--ink-3); color: var(--text-on-dark); font-weight: 700; font-size: .85rem; cursor: pointer;
}
.pw-toggle:hover { background: #3a362e; }
.field-help a { color: var(--gold-hi); }
input[readonly] { opacity: .75; cursor: default; }

/* ---------- Order success ---------- */
.order-success { background: var(--ink-2); border: 1px solid var(--gold); border-radius: var(--radius); padding: var(--s-4); }
@media (min-width: 768px) { .order-success { padding: var(--s-5); } }
.order-success:focus { outline: none; }
.success-title { font-family: var(--f-display); font-stretch: 112%; font-weight: 900; text-transform: uppercase; font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 8px; }
.success-number { font-size: 1.15rem; color: var(--muted-on-dark); }
.success-number strong { display: block; font-family: var(--f-display); font-stretch: 112%; font-weight: 900; font-size: clamp(2rem, 6vw, 3.2rem); color: var(--gold); letter-spacing: .02em; line-height: 1.1; margin-top: 4px; }
.success-summary { margin: var(--s-4) 0; display: grid; gap: 0; border-top: 1px solid var(--ink-3); }
.success-summary div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--ink-3); }
.success-summary dt { color: var(--muted-on-dark); font-size: .9rem; }
.success-summary dd { margin: 0; font-weight: 600; }
.order-success .notice { border: 1px solid var(--gold); border-radius: var(--radius-sm); padding: var(--s-2) var(--s-3); background: rgb(201 164 92 / .08); color: var(--text-on-dark); }
.order-success .notice a { color: var(--gold-hi); font-weight: 700; }
.success-note { margin-top: var(--s-3); color: var(--muted-on-dark); font-size: .92rem; }

/* ---------- App pages (account / admin) ---------- */
.app-page { background: var(--paper); min-height: 100dvh; display: flex; flex-direction: column; }
.app-main { flex: 1; padding: var(--s-5) 0 var(--s-7); }
.app-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.app-title { font-family: var(--f-display); font-stretch: 112%; font-weight: 900; text-transform: uppercase; font-size: clamp(2rem, 5vw, 3.4rem); line-height: .95; }
.app-title em { color: var(--gold-deep); }
.app-sub { color: var(--text-muted); margin-top: 8px; }
.app-footer { background: var(--ink); color: var(--muted-on-dark); padding: var(--s-3) 0; font-size: .9rem; }
.app-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.app-footer a { color: var(--text-on-dark); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-4); box-shadow: 0 1px 2px rgb(14 13 11 / .04); }
.auth-panel { max-width: 460px; margin: 0 auto; }
.auth-panel h2 { font-family: var(--f-display); font-stretch: 112%; font-weight: 800; text-transform: uppercase; font-size: 1.6rem; margin-bottom: var(--s-2); }

/* Light-surface form controls (account/admin) */
.light label, .light .label { color: var(--text); }
.light input, .light select, .light textarea {
  background: #fff; color: var(--text); border-color: #cfc4af;
}
.light input:hover, .light select:hover, .light textarea:hover { border-color: #a99d86; }
.light input:focus-visible, .light select:focus-visible, .light textarea:focus-visible { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgb(122 91 32 / .22); }
.light select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237a5b20' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.light .field-help { color: var(--text-muted); }
.light .field-error { color: var(--danger); }
.light [aria-invalid="true"] { border-color: var(--danger) !important; }
.light .req { color: var(--gold-deep); }
.light .pw-toggle { background: var(--paper-2); color: var(--text); }
.light .segmented { background: var(--paper-2); border-color: var(--line); }
.light .segmented span { color: var(--text-muted); }
.light .segmented input:checked + span { background: var(--ink); color: var(--text-on-dark); }
.light .segmented input:focus-visible + span { outline-color: var(--gold-deep); }

.form-msg { margin-top: var(--s-2); padding: 12px 14px; border-radius: var(--radius-sm); font-size: .95rem; }
.form-msg:empty { display: none; }
.form-msg.ok { background: #eef6ea; color: #24561b; border: 1px solid #b9d8ad; }
.form-msg.err { background: #fbecea; color: var(--danger); border: 1px solid #efc1bb; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); overflow-x: auto; overflow-y: hidden; }
.tab {
  background: none; border: 0; border-bottom: 3px solid transparent;
  min-height: 48px; padding: 0 16px; font-weight: 700; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold-deep); }
.tab .count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--paper-2); font-size: .78rem; }

.empty { text-align: center; padding: var(--s-6) var(--s-3); color: var(--text-muted); }
.empty h3 { font-family: var(--f-display); font-stretch: 112%; font-weight: 800; text-transform: uppercase; color: var(--text); margin-bottom: 8px; }
.empty .btn { margin-top: var(--s-3); }
.loading { padding: var(--s-5); text-align: center; color: var(--text-muted); }

/* Status badges (text + color, never color alone) */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-received      { background: #eef1f6; color: #2c4a7a; border-color: #cfd8e8; }
.status-in_production { background: #fbf3e2; color: #7a5b20; border-color: #ecd9ae; }
.status-shipped       { background: #e9f3f6; color: #1d5c6e; border-color: #bcdbe4; }
.status-delivered     { background: #eaf4e6; color: #2b5d20; border-color: #c2dcb7; }
.status-cancelled     { background: #f4eceb; color: #8a2a22; border-color: #e3c6c2; }
.pay { font-size: .8rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--paper-2); color: var(--text-muted); }
.pay-paid { background: #eaf4e6; color: #2b5d20; }
.pay-refunded { background: #f4eceb; color: #8a2a22; }

/* ---------- Customer order cards ---------- */
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.order-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-3); }
@media (min-width: 768px) { .order-card { padding: var(--s-4); } }
.order-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--s-3); }
.order-no { font-family: var(--f-display); font-stretch: 112%; font-weight: 900; font-size: 1.5rem; letter-spacing: .01em; }
.order-date { color: var(--text-muted); font-size: .92rem; }
.order-grid { display: grid; gap: var(--s-3); }
@media (min-width: 768px) { .order-grid { grid-template-columns: repeat(3, 1fr); } }
.order-grid h4 { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 6px; }
.order-grid p { margin: 0; }
.order-files { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.order-files li { overflow-wrap: anywhere; }

.progress { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; counter-reset: step; }
.progress li { position: relative; padding-top: 14px; font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.progress li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; border-radius: 999px; background: var(--paper-2); }
.progress li.done { color: var(--text); }
.progress li.done::before { background: var(--gold-deep); }
.progress li.current { color: var(--text); font-weight: 800; }

.tracking-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: var(--s-3); }
.tracking-box strong { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.btn-dark-sm { --bg: var(--ink); --fg: var(--text-on-dark); --bd: var(--ink); min-height: 40px; padding: 8px 16px; font-size: .88rem; }

/* ---------- Admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: var(--s-4); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; text-align: left; cursor: pointer; font: inherit; color: inherit; transition: border-color var(--dur); }
.stat:hover { border-color: var(--gold-deep); }
.stat[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.stat-label { display: block; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.stat-num { display: block; font-family: var(--f-display); font-stretch: 112%; font-weight: 900; font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: var(--s-3); }
.toolbar .field { margin: 0; flex: 1 1 220px; }
.toolbar .field-sm { flex: 0 1 200px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 880px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); background: var(--paper); position: sticky; top: 0; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbf8f1; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .muted { color: var(--text-muted); font-size: .86rem; }
.row-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 800; color: var(--gold-deep); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }

/* Order detail drawer */
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(640px, 100vw); max-width: 100vw; padding: 0; border: 0; background: var(--paper); color: var(--text); box-shadow: -20px 0 60px rgb(14 13 11 / .3); }
.drawer::backdrop { background: rgb(14 13 11 / .5); }
.drawer[open] { display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--ink); color: var(--text-on-dark); }
.drawer-head h2 { font-family: var(--f-display); font-stretch: 112%; font-weight: 900; font-size: 1.5rem; }
.drawer-close { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #4a453b; background: transparent; color: inherit; cursor: pointer; }
.drawer-close:hover { border-color: var(--gold); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: var(--s-3); align-content: start; }
.drawer-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }
.drawer-section h3 { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; font-size: .95rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv a { color: var(--gold-deep); }
.file-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-links li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.file-links span { overflow-wrap: anywhere; font-size: .92rem; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.drawer-foot .form-msg { margin: 0; flex: 1 1 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin-top: 2px; accent-color: var(--gold-deep); }
.sent-note { font-size: .88rem; color: var(--text-muted); margin-top: 6px; }
.role-select { min-height: 40px; padding: 6px 36px 6px 10px; width: auto; }

@media (max-width: 599px) {
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* App header nav */
.app-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.app-nav a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 999px; font-weight: 600; font-size: .92rem; text-decoration: none; }
.app-nav a:not(.btn):hover { background: var(--paper-2); }
.app-nav a[aria-current="page"] { background: var(--paper-2); }
@media (max-width: 480px) { .app-nav a:not(.btn) { padding: 0 8px; } .brand img { height: 48px; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tracking-label { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }

.pay-banner { margin: 0 0 var(--s-3, 16px); padding: 12px 16px; border-radius: 10px; border: 1px solid; }
.pay-banner.ok { background: #eaf4e6; border-color: #9cc68f; color: #1f4a17; }
.pay-banner.warn { background: #fbf3e2; border-color: #e2c27e; color: #5a4210; }
.order-grid [data-pay] { margin-top: 8px; }
.order-grid .muted { color: var(--text-muted); font-size: .86rem; }

/* Customers can edit delivery details during their order's first 24 hours. */
.delivery-info { margin-bottom: 16px; max-width: 760px; }
.delivery-note { margin-top: 10px !important; font-size: .86rem; color: var(--text-muted); }
.order-grid [data-edit-delivery] { margin-top: 10px; }
.delivery-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); color: var(--text); box-shadow: 0 16px 60px rgb(14 13 11 / .3); }
.delivery-dialog::backdrop { background: rgb(14 13 11 / .6); }
.delivery-dialog h2 { font-family: var(--f-display); font-size: 1.7rem; line-height: 1.2; }
.delivery-dialog-order { margin-top: 6px; }
.delivery-dialog #delivery-deadline { margin: 6px 0 20px; }
.delivery-dialog form { container-type: inline-size; }
.delivery-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.delivery-dialog [aria-invalid="true"] { border-color: var(--danger); }
@media (max-width: 480px) {
  .delivery-dialog { padding: 20px; }
  .delivery-dialog .field-row-3 { grid-template-columns: 1fr; }
  .delivery-actions .btn { flex: 1 1 auto; }
}

/* Order article ZIP download */
.file-download-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px;}
.file-download-actions [hidden]{display:none;}
.file-download-status{font-size:.9rem;margin:10px 0 0;}
