/* Refilia - wineexpert admin. Desktop first, still usable on a phone. */

/* --- login ---------------------------------------------------------------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
}
.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login__brand { font-size: 22px; color: var(--accent); }
.login__card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 14px 0 2px;
  letter-spacing: -0.02em;
}
.login__sub { margin: 0 0 24px; color: var(--ink-soft); font-size: 14.5px; }

/* --- shell ---------------------------------------------------------------- */

.head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.head__brand { display: flex; align-items: baseline; gap: 8px; }
.head__brand .wordmark { font-size: 21px; color: var(--accent); }
.head__tag { font-size: 12px; color: var(--ink-faint); letter-spacing: 0.1em; text-transform: uppercase; }
.head__logout {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.head__logout:hover { background: var(--paper-deep); }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab[aria-selected='true'] { background: var(--accent-tint); color: var(--accent); }
.tab:hover { background: var(--paper-deep); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 20px 24px 4px;
  max-width: 1180px;
  margin: 0 auto;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat span { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

.panel { padding: 16px 24px 60px; max-width: 1180px; margin: 0 auto; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.02em;
}
.toolbar__right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.toolbar .btn--ghost { margin-left: auto; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
}
.segmented button {
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); }
.btn--ghost { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent-line); }
.btn--ghost:hover { background: var(--accent-tint); }
.btn--quiet { background: var(--paper-deep); color: var(--ink-soft); }
.btn--quiet:hover { background: var(--line); }
.btn--block { width: 100%; min-height: 48px; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  outline: none;
  font-size: 15px;
}
.field input:focus, .field select:focus, .input:focus { border-color: var(--accent); }
.input--search { min-width: 220px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.msg {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px;
  background: var(--ok-tint);
  color: var(--ok);
}
.msg--error { background: var(--warn-tint); color: var(--warn); }

/* --- orders --------------------------------------------------------------- */

.order {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.order__top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.order__venue {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.02em;
  margin: 0 0 3px;
}
.order__meta { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }
.order__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.order__lines { border-top: 1px solid var(--line); }
.order__line {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.order__line:last-child { border-bottom: 0; }
.order__line-name { font-weight: 600; }
.order__line-prod { color: var(--ink-soft); font-size: 13.5px; }
.order__line-ref {
  font-size: 12px;
  color: var(--ink-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.order__line-qty {
  margin-left: auto;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.order__line-qty small { font-weight: 500; color: var(--ink-soft); }
.order__note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gold-tint);
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}
.tag--new { background: var(--accent-tint); color: var(--accent); }
.tag--processed { background: var(--ok-tint); color: var(--ok); }
.tag--cancelled { background: var(--warn-tint); color: var(--warn); }

/* --- tables --------------------------------------------------------------- */

.tablewrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--surface-sunken); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.muted { color: var(--ink-soft); }
.inactive td { opacity: 0.55; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

/* --- modal ---------------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(28, 18, 22, 0.45); }
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  animation: modalIn 0.24s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 12px;
}
.modal__head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; letter-spacing: -0.02em; }
.modal__close { width: 38px; height: 38px; border-radius: 50%; background: var(--paper-deep); color: var(--ink-soft); }
.modal__body { padding: 0 22px; overflow-y: auto; }
.modal__foot { padding: 16px 22px 22px; display: flex; gap: 10px; justify-content: flex-end; }

.qrbox { text-align: center; padding: 8px 0 16px; }
.qrbox img { width: 210px; height: 210px; background: #fff; border-radius: var(--radius); padding: 8px; border: 1px solid var(--line); }
.copyrow {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 14px;
}
.copyrow code { flex: 1; font-size: 12.5px; word-break: break-all; }
.pinbig {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--accent);
  padding: 10px 0 4px;
  font-variant-numeric: tabular-nums;
}

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 16px);
  z-index: 90;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* --- print ---------------------------------------------------------------- */

@media print {
  .head, .stats, .toolbar, .order__actions, .toast, .modal { display: none !important; }
  body { background: #fff; }
  .panel { padding: 0; max-width: none; }
  .order { break-inside: avoid; box-shadow: none; border: 1px solid #999; margin-bottom: 10px; }
}

@media (max-width: 720px) {
  .head { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .panel, .stats { padding-inline: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar__right { width: 100%; margin-left: 0; }
  .input--search { flex: 1; min-width: 0; }
}
