/* Handigo Admin — plain CSS, no framework. Brand colours (--primary/--secondary/--accent) are injected by the layout from branding settings. */
:root {
  --primary: #4F8CFF; --secondary: #2D3748; --accent: #FFC857;
  --bg: #f3f5fa; --card: #ffffff; --text: #141b2d; --muted: #67748c; --line: #e6eaf2; --line-strong: #d6dce8;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px -6px rgba(16,24,40,.08);
  --shadow-lg: 0 24px 60px -20px rgba(11,42,91,.35);
  --ring: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
  --sidebar-w: 256px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 15px; }
h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 18px; }
h3:first-child { margin-top: 0; }
small, .muted { color: var(--muted); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--secondary) 92%, #000) 0%, var(--secondary) 45%, color-mix(in srgb, var(--secondary) 80%, var(--primary)) 100%); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 18px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand img { height: 30px; }
.sidebar .brand { font-size: 22px; gap: 14px; }
.sidebar .brand img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 16px; padding: 4px; box-shadow: 0 10px 24px -14px rgba(0,0,0,.6); flex-shrink: 0; }
.brand .brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 6px 16px -6px rgba(0,0,0,.5); }
.brand small { display: block; font-size: 11px; font-weight: 500; opacity: .6; letter-spacing: .06em; text-transform: uppercase; }
.sidebar nav { padding: 6px 12px 24px; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: rgba(255,255,255,.72); padding: 9px 12px; display: flex; align-items: center; gap: 10px; border-radius: 10px; font-weight: 500; transition: background .15s, color .15s; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.sidebar nav a.active .ic { background: var(--primary); color: #fff; }
.sidebar nav .ic { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); font-size: 14px; flex-shrink: 0; }
.nav-group { padding: 18px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.4); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 22px 18px; font-size: 11px; color: rgba(255,255,255,.4); border-top: 1px solid rgba(255,255,255,.08); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 28px; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { flex: 1; margin: 0; font-size: 18px; }
.topbar .crumb { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.topbar .user { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; }
.user-chip .who small { font-size: 11px; }
.menu-btn { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--text); }
.page { padding: 24px 28px 48px; }

/* ---------- Alerts ---------- */
.alert { margin: 16px 28px 0; padding: 12px 16px 12px 14px; border-radius: var(--radius-sm); border: 1px solid; border-left-width: 4px; display: flex; gap: 10px; align-items: center; animation: slide-in .25s ease-out; }
.alert::before { font-weight: 700; }
.alert-success { background: #ecfdf3; color: #14532d; border-color: #bbf7d0; border-left-color: var(--ok); } .alert-success::before { content: "✓"; color: var(--ok); }
.alert-error { background: #fef2f2; color: #7f1d1d; border-color: #fecaca; border-left-color: var(--bad); } .alert-error::before { content: "!"; color: var(--bad); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title h2 { margin: 0; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 7%, transparent); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; background: #f8fafd; position: sticky; top: 0; }
tr:first-child th:first-child { border-top-left-radius: 10px; } tr:first-child th:last-child { border-top-right-radius: 10px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover td { background: #f8faff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap;
  color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 90%, #fff), var(--primary)); box-shadow: 0 1px 2px rgba(16,24,40,.1), inset 0 1px 0 rgba(255,255,255,.15); transition: transform .1s, filter .15s, box-shadow .15s; }
.btn:hover { filter: brightness(1.05); text-decoration: none; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--primary) 60%, transparent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--ring); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--line-strong); box-shadow: none; }
.btn-ghost:hover { background: #f5f7fb; box-shadow: none; }
.btn-danger { background: linear-gradient(180deg, #ef4444, var(--bad)); } .btn-ok { background: linear-gradient(180deg, #22c55e, var(--ok)); } .btn-warn { background: linear-gradient(180deg, #f59e0b, var(--warn)); }
.btn-accent { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent)); color: #1b2430; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-ok { background: #ecfdf3; color: #15803d; } .badge-warn { background: #fff7ed; color: #b45309; } .badge-bad { background: #fef2f2; color: #b91c1c; } .badge-info { background: #eff4ff; color: #1d4ed8; }

/* ---------- Forms ---------- */
form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #a0aabb; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2367748c' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
textarea { min-height: 96px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: 6px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.inline { display: inline; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 44px; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 2px; background: #fff; }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); }
.preview-logo { height: 40px; background: var(--secondary); padding: 6px 10px; border-radius: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.danger-zone { border-color: #fecaca; background: #fff8f8; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 10px 20px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, #fff); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.chart { height: 220px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters > div { min-width: 160px; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: #eef1f6; }
.msg.staff { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: color-mix(in srgb, var(--primary) 12%, #fff); }
.msg small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; }
code { background: #eef1f6; padding: 2px 6px; border-radius: 6px; font-size: 12px; }
details summary { cursor: pointer; font-weight: 500; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.login-hero { position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -10%, color-mix(in srgb, var(--primary) 70%, #fff) 0%, transparent 55%), linear-gradient(160deg, var(--secondary) 0%, color-mix(in srgb, var(--secondary) 55%, var(--primary)) 100%); }
.login-hero::before, .login-hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); opacity: .25; }
.login-hero::before { width: 420px; height: 420px; right: -140px; bottom: -160px; background: var(--accent); }
.login-hero::after { width: 260px; height: 260px; right: 120px; top: -120px; background: #fff; opacity: .08; }
.login-hero .brand { padding: 0; font-size: 26px; gap: 16px; position: relative; }
.login-hero .brand img { height: 84px; padding: 12px; background: rgba(255,255,255,.95); border-radius: 22px; box-shadow: 0 20px 50px -18px rgba(0,0,0,.55), 0 0 0 8px rgba(255,255,255,.08); }
.login-hero .brand small { font-size: 12px; }
.login-hero h2 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.1; margin: 0 0 16px; font-weight: 750; letter-spacing: -.02em; max-width: 520px; }
.login-hero p { max-width: 460px; font-size: 15px; opacity: .85; margin: 0 0 28px; }
.login-hero ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 460px; }
.login-hero li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.login-hero li .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.14); flex-shrink: 0; font-size: 16px; backdrop-filter: blur(6px); }
.login-hero li b { display: block; font-weight: 600; } .login-hero li span { opacity: .75; font-size: 13px; }
.login-hero .foot { font-size: 12px; opacity: .55; position: relative; }
.login-side { display: grid; place-items: center; padding: 32px 24px; }
.login-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-card .lead { color: var(--muted); margin: 0 0 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card .input-wrap { position: relative; }
.login-card .input-wrap input { padding: 12px 44px 12px 42px; font-size: 14px; }
.login-card .input-wrap .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #9aa5b8; pointer-events: none; display: flex; }
.login-card .input-wrap .toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 8px; border-radius: 6px; }
.login-card .input-wrap .toggle:hover { background: #f1f4f9; color: var(--text); }
.login-card .btn { width: 100%; padding: 12px; font-size: 14px; border-radius: 12px; margin-top: 6px; }
.login-card .alert { margin: 0 0 18px; }
.login-card .brand-mobile { display: flex; justify-content: center; margin: -6px 0 22px; }
.login-card .brand-mobile img { height: 64px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); transition: left .22s ease; z-index: 20; box-shadow: var(--shadow-lg); } .sidebar.open { left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 16px; } .page { padding: 16px; } .alert { margin: 12px 16px 0; }
  .user-chip .who { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; } .login-card .brand-mobile { display: flex; justify-content: center; margin-bottom: 18px; }
}

/* Login quick-fill (dev only) */
.quick-fill { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.pill { border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); background: color-mix(in srgb, var(--primary) 8%, #fff); color: var(--primary); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, transform .1s; }
.pill:hover { background: color-mix(in srgb, var(--primary) 16%, #fff); }
.pill:active { transform: scale(.97); }
