:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #1d2129;
    --muted: #6d7480;
    --line: #e4e7ec;

    /* 3D Services — sampled from the pin logo */
    --brand: #C12927;
    --brand-dark: #931F1E;
    --brand-darker: #7C1214;
    --brand-light: #FCEBEA;
    --accent: #EB1C24;

    /* WhatsApp message previews stay green: they depict a real WhatsApp
       message, so the colour is a comprehension cue, not branding. */
    --wa-bubble: #E7F7DC;
    --wa-bubble-line: #cbe8b4;

    --success: #1f9254;
    --danger: #c0392b;
    --warn: #c77d1a;
    --sidebar: #1B1D22;
    --sidebar-line: rgba(255,255,255,.09);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
    width: 244px;
    flex: 0 0 244px;
    background: var(--sidebar);
    color: #c9ccd3;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 18px; border-bottom: 1px solid var(--sidebar-line);
}
.brand-mark { width: 40px; height: 40px; flex: 0 0 40px; object-fit: contain; }
.login-logo { width: 74px; height: 74px; object-fit: contain; display: block; margin: 0 auto 14px; }
.brand strong { display: block; color: #fff; font-size: 15px; }
.brand small { color: #8b8f99; font-size: 11.5px; }

.sidebar nav { padding: 14px 10px; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; margin-bottom: 3px;
    border-radius: 8px; color: #b0b4bd; font-size: 14.5px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar nav .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--sidebar-line); }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--brand);
    color: #fff; display: grid; place-items: center; font-weight: 700;
}
.who strong { display: block; color: #fff; font-size: 13.5px; }
.who small { color: #8b8f99; font-size: 11.5px; text-transform: capitalize; }
.signout {
    display: block; text-align: center; padding: 8px; border-radius: 7px;
    background: rgba(255,255,255,.07); color: #c9ccd3; font-size: 13px;
}
.signout:hover { background: rgba(255,255,255,.13); text-decoration: none; }

/* ---------- content ---------- */
.content { flex: 1; padding: 26px 30px 50px; min-width: 0; }
.topbar { margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.2px; }
.topbar .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.flash {
    padding: 11px 15px; border-radius: 8px; margin-bottom: 16px;
    border-left: 4px solid var(--success); background: #e9f6ee; font-size: 14px;
}
.flash-error { border-left-color: var(--danger); background: #fdeceb; }
.flash-warn { border-left-color: var(--warn); background: #fdf3e6; }

/* ---------- panels & grid ---------- */
.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); margin-bottom: 20px;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 27px; font-weight: 650; margin-top: 5px; }
.stat .n { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat.good .v { color: var(--success); }
.stat.bad .v { color: var(--danger); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left; padding: 11px 14px; color: var(--muted);
    font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.table-wrap { overflow-x: auto; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------- bits ---------- */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 600; background: #eef1f6; color: var(--muted);
}
.badge.on { background: #e6f5ec; color: var(--success); }
.badge.off { background: #eef1f6; color: var(--muted); }
.badge.err { background: #fdeceb; color: var(--danger); }
.badge.warn { background: #fdf3e6; color: var(--warn); }
.badge.info { background: #e7effd; color: #2c5cc5; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--success); }
.dot.off { background: #b9c2cf; }
.dot.err { background: var(--danger); }

.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f2f5f9; color: var(--ink); }
.btn.danger { background: #fff; border-color: #e6b6b1; color: var(--danger); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line);
    border-radius: 8px; font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(193,41,39,.14);
}
textarea { min-height: 96px; resize: vertical; font-family: inherit; }
select[multiple] { min-height: 150px; }

.checkline { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.checkline input { margin-top: 3px; }
.checkline label { font-weight: 500; font-size: 14px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 170px; }

.msg-preview {
    background: var(--wa-bubble); border-radius: 10px; padding: 12px 14px;
    font-size: 13.5px; white-space: pre-wrap; word-break: break-word;
    border: 1px solid var(--wa-bubble-line); max-width: 460px;
}
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.inline-form { display: inline; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: linear-gradient(140deg, #1B1D22 0%, #4a1513 55%, #7C1214 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 34px; width: 100%; max-width: 380px;
    box-shadow: 0 18px 44px rgba(0,0,0,.28); }
.login-card h1 { margin: 0 0 4px; font-size: 21px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.login-card .btn { width: 100%; padding: 11px; }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; }
    .sidebar nav { display: flex; flex-wrap: wrap; }
    .content { padding: 18px; }
}

/* ---------- toast ---------- */
.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9999;
    background: var(--sidebar);
    color: #fff;
    padding: 12px 18px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 26px rgba(0,0,0,.25);
    border-left: 4px solid var(--success);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .2s ease, transform .2s ease;
    max-width: min(420px, calc(100vw - 44px));
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--danger); }

.btn.copied { background: var(--success); border-color: var(--success); color: #fff; }
