:root {
  --bg: #f2efe3;
  --paper: #fffdf7;
  --ink: #292619;
  --muted: #716c59;
  --olive: #5f5828;
  --dark: #262416;
  --red: #c93b27;
  --green: #2f6b43;
  --line: rgba(53,48,27,.14);
  --shadow: 0 18px 55px rgba(49,43,20,.1);
  --display: "Arial Black", "Segoe UI Black", Impact, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 15px/1.45 var(--body); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.kicker { margin: 0 0 .45rem; color: var(--red); font-size: .7rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }

.login-view { display: grid; min-height: 100dvh; place-items: center; padding: 1rem; background: radial-gradient(circle at 30% 10%, #fff 0, transparent 35%), var(--bg); }
.login-card { width: min(430px, 100%); padding: 2rem; border: 1px solid var(--line); border-radius: 1.7rem; background: var(--paper); box-shadow: var(--shadow); }
.admin-brand { display: inline-flex; align-items: center; gap: .75rem; margin-bottom: 2.7rem; text-decoration: none; }
.admin-brand span { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; color: #fff; background: var(--dark); font: 900 .8rem/1 var(--display); }
.admin-brand strong { font: 900 .95rem/1 var(--display); }
.admin-brand.inverse { color: #fff9dc; }
.admin-brand.inverse span { color: var(--dark); background: #eddb8e; }
.login-card h1, .admin-header h1, .panel-card h2 { margin: 0; font-family: var(--display); letter-spacing: -.05em; line-height: 1; }
.login-card h1 { margin-bottom: 1.7rem; font-size: 2.1rem; }
.login-card label, .settings-form label, .password-form label { display: grid; gap: .4rem; margin-bottom: 1rem; }
.login-card label > span, .settings-form label > span, .password-form label > span { font-size: .76rem; font-weight: 800; }
input, textarea, select { width: 100%; min-height: 46px; padding: .75rem .85rem; color: var(--ink); border: 1px solid var(--line); border-radius: .8rem; background: #fff; outline: none; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--olive); box-shadow: 0 0 0 3px rgba(95,88,40,.1); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); }
.login-card small { display: block; margin-top: 1rem; color: var(--muted); font-size: .7rem; }
.error-message { min-height: 1.2rem; color: var(--red); font-size: .78rem; }
.primary-button, .secondary-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border-radius: .8rem; padding: .7rem 1rem; font-weight: 850; text-decoration: none; }
.primary-button { width: 100%; color: #fff; border: 0; background: var(--dark); }
.secondary-button { color: var(--ink); border: 1px solid var(--line); background: #fff; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(201,59,39,.25); outline-offset: 2px; }

.admin-app { min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; display: flex; width: 245px; flex-direction: column; padding: 1.5rem 1.1rem; color: #d9d2b6; background: var(--dark); }
.sidebar nav { display: grid; gap: .45rem; }
.nav-button { display: flex; gap: .8rem; align-items: center; width: 100%; padding: .8rem; color: #c3bda4; text-align: left; border: 0; border-radius: .8rem; background: transparent; font-weight: 750; }
.nav-button span { color: #858068; font-size: .66rem; }
.nav-button:hover, .nav-button.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-button.active span { color: #efd36f; }
.sidebar-bottom { display: grid; gap: .4rem; margin-top: auto; }
.sidebar-bottom a, .sidebar-bottom button { padding: .65rem .8rem; color: #aaa58e; text-align: left; border: 0; background: none; font-size: .78rem; text-decoration: none; }
.sidebar-bottom a:hover, .sidebar-bottom button:hover { color: #fff; }
.admin-content { margin-left: 245px; padding: 0 clamp(1rem, 3vw, 3rem) 4rem; }
.admin-header { display: flex; min-height: 105px; align-items: center; justify-content: space-between; gap: 2rem; }
.admin-header h1 { font-size: 2.1rem; }
.admin-user { display: flex; gap: .7rem; align-items: center; color: var(--muted); font-size: .78rem; }
.admin-user i { width: 11px; height: 11px; border-radius: 50%; background: #38a35d; box-shadow: 0 0 0 4px rgba(56,163,93,.12); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metrics article { display: grid; min-height: 142px; align-content: space-between; padding: 1.15rem; border: 1px solid var(--line); border-radius: 1.2rem; background: var(--paper); box-shadow: var(--shadow); }
.metrics article > span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.metrics strong { font: 900 2rem/1 var(--display); letter-spacing: -.05em; }
.metrics small { color: var(--muted); font-size: .68rem; }
.metrics .attention { color: #fff7df; background: var(--red); }
.metrics .attention span, .metrics .attention small { color: rgba(255,247,223,.72); }
.metrics .revenue { color: #fff9db; background: var(--olive); }
.metrics .revenue span, .metrics .revenue small { color: rgba(255,249,219,.72); }

.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 190px auto auto; gap: .7rem; margin: 1rem 0; }
.orders-shell { overflow: hidden; border: 1px solid var(--line); border-radius: 1.2rem; background: var(--paper); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { padding: .8rem 1rem; color: var(--muted); text-align: left; border-bottom: 1px solid var(--line); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 1rem; vertical-align: top; border-bottom: 1px solid var(--line); font-size: .78rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbf8ec; }
.order-main { display: grid; gap: .2rem; }
.order-main strong { font-size: .82rem; }
.order-main span, .cell-stack span { color: var(--muted); font-size: .68rem; }
.cell-stack { display: grid; gap: .18rem; }
.cell-stack a { font-weight: 800; text-decoration: none; }
.amount-cell strong { display: block; font-size: .9rem; }
.amount-cell span { color: var(--muted); font-size: .67rem; }
.payment-badge { display: inline-flex; padding: .3rem .5rem; border-radius: 999px; color: #775314; background: #fff0bd; font-size: .65rem; font-weight: 800; }
.payment-badge.success { color: #236039; background: #dff4e4; }
.payment-badge.failure { color: #8e2f21; background: #f8ded8; }
.status-select { min-width: 145px; min-height: 38px; padding: .45rem .55rem; font-size: .72rem; }
.comment-line { display: block; max-width: 220px; margin-top: .3rem; color: var(--muted); font-size: .65rem; }
.empty-state { display: grid; min-height: 250px; place-content: center; gap: .4rem; padding: 2rem; text-align: center; }
.empty-state span { color: var(--muted); }

.tab-panel { padding-bottom: 2rem; }
.settings-form { display: grid; gap: 1rem; max-width: 1000px; }
.panel-card { padding: 1.5rem; border: 1px solid var(--line); border-radius: 1.2rem; background: var(--paper); box-shadow: var(--shadow); }
.panel-card h2 { margin-bottom: 1.2rem; font-size: 1.7rem; }
.intro-card { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.toggle { display: flex !important; grid-template-columns: auto auto 1fr; align-items: center; gap: .65rem !important; margin: 0 !important; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle > span { position: relative; width: 48px; height: 27px; border-radius: 999px; background: #c9c5b7; transition: background .2s ease; }
.toggle > span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .2s ease; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(21px); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.settings-form label small { min-height: 1em; color: var(--red); font-size: .65rem; }
.price-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; }
.form-actions p { margin: 0; color: var(--red); font-size: .75rem; }
.form-actions .primary-button { width: auto; min-width: 190px; }
.security-grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(0, 1.2fr); gap: 1rem; max-width: 1000px; }
.password-form > p:not(.kicker), .safety-card > p { color: var(--muted); font-size: .8rem; }
.password-form .primary-button { margin-top: .5rem; }
#passwordMessage { min-height: 1rem; color: var(--red); }
.safety-card ul { display: grid; gap: .8rem; padding-left: 1.2rem; color: #514d3c; }
.backup-note { margin-top: 1.5rem; padding: 1rem; border-left: 4px solid var(--olive); background: var(--bg); }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; max-width: 340px; padding: .8rem 1rem; color: #fff; border-radius: .8rem; background: var(--dark); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: none; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr 180px; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: .7rem; padding: .7rem; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; }
  tbody tr:hover { background: #fff; }
  td { padding: 0; border: 0; }
  td:last-child { grid-column: 2 / -1; }
  .price-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .sidebar { position: sticky; top: 0; display: grid; width: 100%; height: auto; grid-template-columns: auto 1fr; align-items: center; padding: .65rem .8rem; }
  .sidebar .admin-brand { margin: 0; }
  .sidebar .admin-brand strong { display: none; }
  .sidebar .admin-brand span { width: 36px; height: 36px; }
  .sidebar nav { display: flex; justify-content: flex-end; }
  .nav-button { width: auto; padding: .65rem; font-size: .72rem; }
  .nav-button span { display: none; }
  .sidebar-bottom { display: none; }
  .admin-content { margin-left: 0; padding-inline: .8rem; }
  .admin-header { min-height: 85px; }
  .admin-header h1 { font-size: 1.6rem; }
  .metrics { gap: .6rem; }
  .metrics article { min-height: 118px; padding: .9rem; }
  .metrics strong { font-size: 1.5rem; }
  .toolbar { grid-template-columns: 1fr; }
  tbody tr { grid-template-columns: 1fr 1fr; }
  td:last-child { grid-column: auto; }
  .intro-card { align-items: flex-start; flex-direction: column; }
  .form-grid, .price-grid, .security-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .primary-button { width: 100%; }
}

@media (max-width: 430px) {
  .nav-button { font-size: .66rem; }
  .admin-user { display: none; }
  .metrics { grid-template-columns: 1fr; }
  tbody tr { grid-template-columns: 1fr; }
  .login-card { padding: 1.35rem; }
}
