:root {
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --red: #dc2626;
}

* { box-sizing: border-box; }
body.admin {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
}
a { color: var(--accent); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 auto;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-size: 16px; font-weight: 800; line-height: 1.25; color: #fff; letter-spacing: 0.3px; }
.brand span { display: block; font-size: 10px; font-weight: 700; letter-spacing: 2px; color: #9ca3af; margin-top: 6px; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  display: block;
  color: #cbd2dc;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.on { background: var(--accent); color: #fff; }

.sidefoot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.sideuser { color: #9ca3af; padding: 0 12px; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.sidefoot a { color: #9ca3af; text-decoration: none; padding: 0 12px; }
.sidefoot a:hover { color: #fff; }
.linklike {
  background: none;
  border: none;
  color: #fca5a5;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0 12px;
  text-align: left;
}
.linklike:hover { color: #fecaca; }

.content { flex: 1; min-width: 0; padding: 26px clamp(14px, 3vw, 40px); max-width: 1160px; }
h1 { font-size: 24px; margin: 0 0 18px; letter-spacing: -0.02em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { margin: 0; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.muted { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 4px 0 14px; }
.small { font-size: 12.5px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 5px; color: #374151; }
input[type="text"], input[type="password"], input[type="date"], input[type="month"],
input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  max-width: 460px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
  color: var(--ink);
}
textarea {
  max-width: 100%;
  min-height: 140px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--accent); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: #374151; margin: 0; }
.check input { width: auto; margin: 0; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #e5e7eb; color: #111827; }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.full { width: 100%; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.list th {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
table.list td { padding: 10px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }

.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.rowacts { display: flex; gap: 6px; align-items: center; }
.rowacts form { display: inline; }

.badge {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  letter-spacing: 0.03em;
}
.badge.ok { background: #ecfdf5; color: #047857; }
.badge.warn { background: #fffbeb; color: #b45309; }

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-weight: 600;
  font-size: 14px;
  white-space: pre-line;
  line-height: 1.5;
}
.flash.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.flash.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { background: #f9fafb; border: 1px solid var(--line); border-radius: 12px; padding: 14px 22px; min-width: 130px; }
.statnum { display: block; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.statlabel { color: var(--muted); font-size: 12.5px; font-weight: 600; }

.filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.filters > div { flex: 0 1 220px; }
.filters select, .filters input { max-width: none; }
.filterbtns { display: flex; gap: 8px; }

.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 16px; font-size: 13px; color: var(--muted); }

.sample {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  margin: 0 0 16px;
}

.photopreview {
  margin-bottom: 10px;
}
.photopreview img {
  width: 172px;
  height: 128px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
  display: block;
}

.dashhint { max-width: 900px; }

.marketcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.marketcard {
  margin-bottom: 0;
  border-left: 5px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.marketcard.complete { border-left-color: #059669; }
.marketcard.awaiting-jodi { border-left-color: #d97706; }
.marketcard.open-only { border-left-color: #ea580c; }
.marketcard.holiday { border-left-color: #6366f1; }

.flowguide {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}
.flowstep {
  display: flex;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 13px 16px;
}
.flownum {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
}
.flowstep strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.flowstep p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.flowstep em { color: #b45309; font-style: normal; font-weight: 700; }

.mc-opt {
  font-size: 9.5px;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  border-radius: 999px;
  padding: 1px 5px;
  margin-left: 3px;
  text-transform: uppercase;
}

.mc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mc-name { font-weight: 800; font-size: 15px; letter-spacing: 0.01em; }
.mc-time { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.mc-preview {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px dashed #fecaca;
  border-radius: 9px;
  padding: 7px 12px;
  text-align: center;
}

.mc-inputs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.mc-inputs label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 3px; }
.mc-inputs input {
  width: 100%;
  max-width: none;
  padding: 9px 8px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  font-family: ui-monospace, Consolas, monospace;
}
.mc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.check.small { font-size: 12.5px; }

.badge.tag { background: #fef3c7; color: #92400e; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #111827, #1f2937);
  padding: 18px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: min(390px, 94vw);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.login-brand { font-size: 20px; font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.login-brand span { display: block; font-size: 10px; letter-spacing: 2.5px; color: var(--muted); margin-top: 5px; font-weight: 700; }
.login-card .muted { margin: 6px 0 16px; }
.login-card .stack { gap: 14px; }
.login-card .btn.full { margin-top: 4px; }
.login-foot { margin: 16px 0 0; text-align: center; font-size: 13px; }
.login-foot a { text-decoration: none; }

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: static; height: auto; width: auto; flex-direction: column; gap: 12px; padding: 14px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidefoot { margin-top: 0; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
  .content { padding: 18px 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  input[type="text"], input[type="password"], input[type="date"], input[type="month"],
  input[type="number"], input[type="file"], select { max-width: 100%; }
}

@media (max-width: 640px) {
  .content { padding: 14px 10px; }
  h1 { font-size: 20px; }
  .pagehead { margin-bottom: 14px; }
  .card { padding: 15px 13px; border-radius: 12px; }
  .sidebar { padding: 12px 10px; gap: 10px; }
  .sidebar nav a { padding: 9px 10px; font-size: 13px; }
  .brand { font-size: 14px; }
  .marketcards { grid-template-columns: 1fr; gap: 12px; }
  .marketcard { padding: 14px 12px; gap: 10px; }
  .mc-preview { font-size: 18px; padding: 6px 9px; }
  .mc-inputs { gap: 6px; }
  .mc-inputs input { padding: 9px 5px; font-size: 14px; }
  .mc-name { font-size: 14px; }
  .btn { padding: 10px 15px; font-size: 13.5px; }
  .btn.small { padding: 7px 10px; font-size: 12px; }
  table.list { min-width: 560px; }
  .stats { gap: 10px; }
  .stat { padding: 11px 15px; min-width: 104px; }
  .statnum { font-size: 21px; }
  .flash { padding: 10px 12px; font-size: 13px; }
  .filters { gap: 10px; }
  .filters > div { flex: 1 1 100%; }
  textarea { min-height: 180px; font-size: 12.5px; }
}
