/* Operation Rollout (PHP build) — styles matched to the original app's
   shadcn/slate design system. Class names unchanged from before. */

:root {
  --background: #ffffff;
  --foreground: #020817;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --primary: #0f172a;
  --primary-foreground: #f8fafc;
  --secondary: #f1f5f9;
  --destructive: #ef4444;
  --radius: 8px;       /* lg */
  --radius-md: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f9fafb;
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
}
a { color: #2563eb; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* Layout — max-w-6xl (1152px) like the original */
.wrap { max-width: 1152px; margin: 0 auto; padding: 0 16px; }
header.appbar { border-bottom: 1px solid var(--border); background: #fff; }
.appbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { height: 32px; width: 32px; border-radius: var(--radius-md); background: transparent; object-fit: contain; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.brand h1 { font-size: 18px; margin: 0; line-height: 1.15; font-weight: 700; }
.brand p { font-size: 11px; color: var(--muted-foreground); margin: 0; }
.topnav { display: flex; gap: 4px; margin-left: 24px; }
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .name { font-weight: 500; }
main { padding: 24px 16px; }

/* Buttons — match shadcn variants/sizes */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--foreground);
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(15,23,42,.35); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: #1e293b; }
.btn-danger { background: var(--destructive); border-color: var(--destructive); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--muted); }
.btn-active { background: var(--secondary); border-color: transparent; color: var(--foreground); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn-icon { height: 40px; width: 40px; padding: 0; }
.btn-sm.btn-icon { height: 36px; width: 36px; }

/* Cards — rounded-lg, 1px border, shadow-sm, p-6 (no header divider) */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.card-head { padding: 24px 24px 0; display: flex; flex-direction: column; gap: 6px; }
.card-head.spread { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.card-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-desc { font-size: 14px; color: var(--muted-foreground); margin: 0; }
.card-body { padding: 16px 24px 24px; }
.card-body.grid-wrap { padding: 16px 24px 24px; }

/* Tabs — muted bar, white active pill with shadow */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--muted); padding: 4px; border-radius: var(--radius-md); margin-bottom: 16px; }
.tab { padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 500; border: none; background: transparent; color: var(--muted-foreground); transition: all .15s; }
.tab:hover { color: var(--foreground); }
.tab.active { background: #fff; color: var(--foreground); box-shadow: var(--shadow-sm); }

/* Forms */
label { font-size: 14px; font-weight: 500; display: block; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=file], select {
  width: 100%; height: 40px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 14px; background: #fff; color: var(--foreground); font-family: inherit;
}
input[type=file] { padding: 7px 12px; }
input:focus, select:focus { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(15,23,42,.25); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
th { color: var(--muted-foreground); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: none; }

/* Badges — pill, text-xs font-semibold */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-manager { background: #dbeafe; color: #1d4ed8; }
.badge-leader { background: #d1fae5; color: #047857; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: var(--muted); color: var(--muted-foreground); }
.log-row-failure { background: rgba(239, 68, 68, 0.08); }

/* Leaderboard */
.lb-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: #fff; box-shadow: var(--shadow-sm); }
.lb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rank { height: 36px; width: 36px; border-radius: 999px; background: var(--muted); color: #4b5563; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.rank.medal-0 { background: #fde68a; color: #92400e; }
.rank.medal-1 { background: #e5e7eb; color: #374151; }
.rank.medal-2 { background: #fed7aa; color: #9a3412; }
.lb-name { font-weight: 600; }
.lb-wins { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }
.lb-points { font-size: 24px; font-weight: 700; }
.pts-pos { color: #047857; } .pts-neg { color: #b91c1c; } .pts-zero { color: #9ca3af; }
.tint-0 { background: #6ee7b7; } .tint-1 { background: #a7f3d0; } .tint-2 { background: #d1fae5; }
.self-ring { outline: 2px solid #3b82f6; outline-offset: 1px; }
.celebrate { border: 2px solid #fcd34d; background: linear-gradient(90deg,#fffbeb,#fefce8); border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

/* Welcome banner (matches original soft-blue dismissible banner) */
.welcome { display: flex; align-items: flex-start; gap: 12px; border: 1px solid #bfdbfe; background: #eff6ff; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.welcome .wb-icon { flex-shrink: 0; margin-top: 1px; font-size: 18px; line-height: 1.2; }
.welcome .wb-title { font-weight: 600; font-size: 14px; color: #1e3a8a; margin: 0; }
.welcome .wb-body { font-size: 14px; color: #1e40af; margin-top: 4px; }
.welcome .wb-x { flex-shrink: 0; border: none; background: transparent; color: #2563eb; cursor: pointer; height: 24px; width: 24px; border-radius: var(--radius-md); font-size: 13px; line-height: 1; }
.welcome .wb-x:hover { background: #dbeafe; color: #1e3a8a; }

/* User-management table scroll */
.grid-wrap { overflow-x: auto; }
.chk { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* Tracker grid — CSS grid with sticky header + sticky label column,
   self-scrolling container (matches the original layout exactly). */
.trk-scroll { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: auto; max-height: calc(100vh - 250px); min-height: 400px; box-shadow: var(--shadow-sm); }
.trk-grid { display: grid; }
.trk-headrow { position: sticky; top: 0; z-index: 30; background: #fff; box-shadow: var(--shadow-sm); border-bottom: 1px solid var(--border); }
.trk-corner { position: sticky; left: 0; z-index: 40; background: #fff; border-right: 1px solid var(--border); padding: 12px; font-weight: 600; font-size: 14px; }
.trk-lead { padding: 8px; text-align: center; border-left: 1px solid var(--border); }
.trk-lead .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk-lead .tot { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.trk-cat { background: #f1f5f9; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 8px 12px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.trk-row { align-items: center; }
.trk-rowline { border-top: 1px solid var(--border); }
.trk-label { position: sticky; left: 0; z-index: 10; background: #fff; border-right: 1px solid var(--border); padding: 8px 12px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trk-label .lp { font-size: 12px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; flex-shrink: 0; }
.trk-row:hover .trk-label, .trk-row:hover .trk-cell { background: #f8fafc; }
.trk-cell { display: flex; align-items: center; justify-content: center; padding: 8px 0; border-left: 1px solid var(--border); }
.trk-sub { align-items: center; border-top: 2px solid #e5e7eb; background: #f8fafc; }
.trk-sub .trk-label { background: #f8fafc; font-size: 12px; font-weight: 600; color: #374151; }
.trk-subcell { display: flex; align-items: center; justify-content: center; padding: 8px 0; border-left: 1px solid var(--border); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.trk-total { align-items: center; border-top: 4px solid #d1d5db; background: #f1f5f9; }
.trk-total .trk-label { background: #f1f5f9; font-weight: 700; color: #1f2937; }
.trk-totcell { display: flex; align-items: center; justify-content: center; padding: 12px 0; border-left: 1px solid var(--border); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.col-hover { background: #eff6ff !important; }
.lnk { border: none; background: none; color: var(--muted-foreground); cursor: pointer; font-size: 12px; padding: 0; }
.lnk:hover { color: var(--foreground); text-decoration: underline; }
.btn-x { flex: 0 0 20px; width: 20px; height: 28px; border: none; background: none; color: #b91c1c; cursor: pointer; font-size: 14px; padding: 0; line-height: 1; }
.btn-x:hover { color: #7f1d1d; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-col { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 8px; }
.login-logo-img { height: 128px; width: auto; }
.login-card { width: 100%; max-width: 384px; }
.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 0; top: 0; height: 40px; width: 42px; display: flex; align-items: center; justify-content: center; border: none; background: transparent; color: var(--muted-foreground); cursor: pointer; }
.pw-toggle:hover { color: var(--foreground); }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 10px 12px; border-radius: var(--radius-md); font-size: 14px; margin-bottom: 12px; }

/* Toast */
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--foreground); color: #fff; padding: 12px 14px; border-radius: var(--radius-md); font-size: 13px; max-width: 340px; box-shadow: 0 10px 25px rgba(0,0,0,.2); }
.toast.error { background: var(--destructive); }
.toast .t-title { font-weight: 600; }
.toast .t-desc { opacity: .9; font-size: 12px; margin-top: 2px; }

/* Misc */
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-gap { margin-top: 16px; }
.loading { padding: 48px; text-align: center; color: var(--muted-foreground); }

/* ---- Display (TV) mode: clean, big, read-only ---- */
.display-mode .appbar-inner { padding-top: 6px; padding-bottom: 6px; }
.display-mode #content { padding-top: 10px; }
.display-mode .brand p { display: none; }
