/* ───────── Brutalist palette ───────── */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300..700&display=swap");

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --cream: #FAF5E8;
    --cream-soft: #F2EBD9;
    --paper: #FFFDF6;

    --ink: #0F0F0F;
    --ink-soft: #2A2A2A;
    --ink-muted: #555;

    --teal: #1C4B62;
    --teal-dark: #0E3142;
    --teal-soft: rgba(28, 75, 98, 0.10);

    --yellow: #E8A519;
    --yellow-soft: rgba(232, 165, 25, 0.18);

    --red: #CD3318;
    --red-soft: rgba(205, 51, 24, 0.10);

    --border: 2px solid var(--ink);
    --border-thick: 3px solid var(--ink);
    --shadow-hard: 5px 5px 0 var(--ink);
    --shadow-hard-sm: 3px 3px 0 var(--ink);
    --shadow-hard-lg: 8px 8px 0 var(--ink);
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--cream);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--teal);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--red);
}

h1,
h2,
h3,
h4 {
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 28px;
    line-height: 1.05;
    text-transform: uppercase;
}

h2 {
    font-size: 18px;
    text-transform: uppercase;
}

h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.muted {
    color: var(--ink-muted);
}

.text-soft {
    color: var(--ink-soft);
}

.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.mt-8 {
    margin-top: 8px;
}

.hidden {
    display: none !important;
}

.spacer {
    flex: 1;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.row>* {
    margin: 0;
}

.row.tight {
    gap: 8px;
}

.col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ───────── Forms ───────── */
.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: var(--border);
    border-radius: 0;
    font-size: 14px;
    font-family: inherit;
    background: var(--paper);
    color: var(--ink);
    transition: box-shadow 80ms;
    font-weight: 500;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--ink-muted);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    box-shadow: var(--shadow-hard-sm);
    transform: translate(-1px, -1px);
}

.field input:disabled,
.field select:disabled {
    background: var(--cream-soft);
    color: var(--ink-muted);
    cursor: not-allowed;
}

/* Catch-all so bare inputs (campaign.html etc.) inherit brutalist style */
textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
select {
    background: var(--paper);
    color: var(--ink);
    border: var(--border);
    border-radius: 0;
    font-family: inherit;
    font-weight: 500;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    box-shadow: var(--shadow-hard-sm);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--teal);
    width: 16px;
    height: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: var(--border);
    border-radius: 0;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
    transition: transform 80ms, box-shadow 80ms, background 120ms;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-decoration: none;
}

.btn:hover {
    background: var(--cream-soft);
}

.btn:active,
.btn:focus {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--ink);
    outline: none;
}

.btn-primary {
    background: var(--teal);
    color: var(--paper);
}

.btn-primary:hover {
    background: var(--teal-dark);
    color: var(--paper);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-hard-sm);
}

.btn-ghost {
    background: transparent;
}

.btn-ghost:hover {
    background: var(--cream-soft);
}

.btn-danger {
    background: var(--red);
    color: var(--paper);
}

.btn-danger:hover {
    background: #a52810;
    color: var(--paper);
}

.btn-accent {
    background: var(--yellow);
    color: var(--ink);
}

.btn-accent:hover {
    background: #d3940f;
    color: var(--ink);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 11px;
    box-shadow: 2px 2px 0 var(--ink);
}

.btn-sm:active,
.btn-sm:focus {
    box-shadow: 1px 1px 0 var(--ink);
}

/* <select> styled to match .btn dimensions exactly — used for inline page
   filters (e.g. "All employees") that sit next to action buttons. */
select.btn-select {
    padding: 9px 30px 9px 18px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: var(--border);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
    cursor: pointer;
    line-height: 1.2;
    font-family: inherit;
}
select.btn-select:focus { box-shadow: var(--shadow-hard-sm); transform: none; outline: none; }

.alert {
    padding: 12px 14px;
    border-radius: 0;
    margin-bottom: 14px;
    font-size: 13.5px;
    border: var(--border);
    box-shadow: var(--shadow-hard-sm);
    font-weight: 500;
}

.alert-error {
    background: var(--red);
    color: var(--paper);
}

.alert-success {
    background: #1f7a3a;
    color: var(--paper);
}

.alert-info {
    background: var(--yellow);
    color: var(--ink);
}

/* ───────── Auth shell ───────── */
.auth-shell {
    min-height: 100vh;
    background: var(--cream);
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background-image:
        repeating-linear-gradient(45deg, transparent 0 18px, rgba(28, 75, 98, 0.06) 18px 19px),
        radial-gradient(ellipse 700px 500px at 80% 90%, var(--yellow-soft), transparent 60%);
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--paper);
    border: var(--border-thick);
    border-radius: 0;
    box-shadow: var(--shadow-hard-lg);
    padding: 36px;
    color: var(--ink);
}

.auth-card h1 {
    margin: 0 0 4px;
}

.auth-card .brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding: 6px 14px;
    background: var(--yellow);
    border: var(--border);
    box-shadow: var(--shadow-hard-sm);
    color: var(--ink);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 13px;
}

.auth-card .brand-dot {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: block;
}

.auth-card .subtitle {
    margin: 0 0 24px;
    color: var(--ink-soft);
    font-size: 14px;
}

/* ───────── App shell ───────── */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--yellow);
    color: var(--ink);
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    /* overflow visible so the role sticker can spill out across the
       sidebar's right edge into the main pane. z-index lifts the whole
       sidebar above the main pane so the overflowing sticker isn't
       hidden behind .main / .topbar. */
    overflow: visible;
    z-index: 20;
    border-right: var(--border-thick);
}

.sidebar .brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.01em;
    margin: 14px 0 28px;
    padding: 8px 12px;
    text-transform: uppercase;
    background: var(--paper);
    border: var(--border);
    box-shadow: var(--shadow-hard-sm);
    overflow: visible;
}

.sidebar .brand-dot {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: block;
}

/* Role sticker — slapped on top of the brand box at a tilt, intentionally
   spilling past the sidebar's right edge into the main pane. */
.sidebar .brand .role-sticker {
    position: absolute;
    top: -22px;
    right: -35px;
    transform: rotate(12deg);
    transform-origin: center;
    padding: 7px 20px;
    background: var(--red);
    color: var(--paper);
    border: var(--border);
    box-shadow: var(--shadow-hard);
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    z-index: 10;
    pointer-events: none;
    white-space: nowrap;
    background-image: linear-gradient(135deg, transparent 49%, rgba(0, 0, 0, 0.06) 50%, transparent 51%);
}

.sidebar .brand .role-sticker--admin {
    background: var(--red);
    color: var(--paper);
}

.sidebar .brand .role-sticker--employee {
    background: var(--teal);
    color: var(--paper);
    transform: rotate(-10deg);
    top: -20px;
    right: -35px;
}

.sidebar .nav-group-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--ink);
    font-weight: 800;
    padding: 16px 12px 6px;
    opacity: 0.65;
}

.sidebar a.nav-item,
.sidebar button.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 2px solid transparent;
    border-radius: 0;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 700;
    transition: background 100ms, border-color 100ms, transform 80ms, box-shadow 80ms;
    text-decoration: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    width: 100%;
    text-align: left;
}

.sidebar a.nav-item:hover,
.sidebar button.nav-item:hover {
    background: var(--paper);
    border-color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
    text-decoration: none;
    transform: translate(-1px, -1px);
}

.sidebar a.nav-item.active,
.sidebar button.nav-item.active {
    background: var(--teal);
    color: var(--paper);
    border-color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.sidebar .footer {
    margin-top: auto;
    padding: 14px 10px 4px;
    border-top: 2px solid var(--ink);
    font-size: 12.5px;
    color: var(--ink);
}

.sidebar .footer .who {
    font-weight: 800;
}

.sidebar .footer .role {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: var(--ink);
    color: var(--paper);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.sidebar .footer .btn {
    margin-top: 12px;
    width: 100%;
    background: var(--red);
    color: var(--paper);
}

.sidebar .footer .btn:hover {
    background: #a52810;
}

.main {
    background: var(--cream);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: var(--cream);
    border-bottom: var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
}

.topbar .ws-switcher {
    padding: 7px 12px;
    border: var(--border);
    border-radius: 0;
    background: var(--paper);
    font-family: inherit;
    font-size: 13px;
    min-width: 220px;
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow-hard-sm);
}

.page {
    padding: 24px 28px 40px;
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ───────── Cards & panels ───────── */
.card {
    background: var(--paper);
    border: var(--border);
    border-radius: 0;
    box-shadow: var(--shadow-hard);
    padding: 22px 22px;
    margin-bottom: 22px;
}

.card .card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ink);
}

.card .card-header h2 {
    margin: 0;
    flex: 1;
}

.card .card-sub {
    color: var(--ink-soft);
    margin-top: -4px;
    margin-bottom: 18px;
    font-size: 13.5px;
}

/* Stat strip */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat {
    background: var(--paper);
    border: var(--border);
    border-radius: 0;
    padding: 18px 18px;
    box-shadow: var(--shadow-hard);
    position: relative;
    overflow: hidden;
}

.stat:nth-child(4n+1) {
    background: var(--paper);
}

.stat:nth-child(4n+2) {
    background: var(--yellow);
}

.stat:nth-child(4n+3) {
    background: var(--teal);
    color: var(--paper);
}

.stat:nth-child(4n+3) .label,
.stat:nth-child(4n+3) .delta {
    color: rgba(255, 253, 246, 0.85);
}

.stat:nth-child(4n+3) .value {
    color: var(--paper);
}

.stat:nth-child(4n) {
    background: var(--red);
    color: var(--paper);
}

.stat:nth-child(4n) .label,
.stat:nth-child(4n) .delta {
    color: rgba(255, 253, 246, 0.85);
}

.stat:nth-child(4n) .value {
    color: var(--paper);
}

.stat .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink);
    font-weight: 800;
}

.stat .value {
    font-size: 36px;
    font-weight: 800;
    color: var(--ink);
    margin-top: 4px;
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat .delta {
    font-size: 12px;
    color: var(--ink-muted);
    margin-top: 6px;
    font-weight: 600;
}

/* Layouts */
.split {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 22px;
}

.split-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

@media (max-width: 1100px) {

    .split,
    .split-3 {
        grid-template-columns: 1fr;
    }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

/* ───────── Tables ───────── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    color: var(--ink);
}

th,
td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 2px solid var(--ink);
}

tr:last-child td {
    border-bottom: none;
}

th {
    font-weight: 800;
    color: var(--ink);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--cream-soft);
    border-bottom: 3px solid var(--ink);
}

tbody tr {
    transition: background 100ms;
}

tbody tr:hover {
    background: var(--cream-soft);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 800;
    background: var(--cream-soft);
    color: var(--ink);
    border: 2px solid var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.ok {
    background: #1f7a3a;
    color: var(--paper);
}

.badge.warn {
    background: var(--yellow);
    color: var(--ink);
}

.badge.err {
    background: var(--red);
    color: var(--paper);
}

.badge.info {
    background: var(--teal);
    color: var(--paper);
}

.badge.muted {
    background: var(--cream-soft);
    color: var(--ink);
}

/* ───────── Modal ───────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.55);
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 100;
}

.modal {
    background: var(--paper);
    color: var(--ink);
    border: var(--border-thick);
    border-radius: 0;
    padding: 26px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-hard-lg);
}

.modal h3 {
    margin-top: 0;
    font-size: 20px;
    text-transform: uppercase;
    border-bottom: 3px solid var(--ink);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

/* Entity card (clients, etc.) */
.entity-card {
    background: var(--paper);
    border: var(--border);
    border-radius: 0;
    padding: 18px;
    box-shadow: var(--shadow-hard);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 100ms, box-shadow 100ms;
}

.entity-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-hard-lg);
}

.entity-card .title {
    font-weight: 800;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: -0.005em;
}

.entity-card .meta {
    font-size: 12.5px;
    color: var(--ink-soft);
}

.entity-card .actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.copy-field {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.copy-field input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

/* Empty states */
.empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 14px;
    border: 2px dashed var(--ink);
    background: var(--cream-soft);
}

.empty .empty-title {
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 6px;
    font-weight: 800;
    text-transform: uppercase;
}

/* ───────── Skeleton loaders ───────── */
@keyframes brutalist-pulse {

    0%,
    100% {
        background-color: var(--cream-soft);
    }

    50% {
        background-color: #E5DCC4;
    }
}

.skel {
    display: block;
    background: var(--cream-soft);
    border: 2px solid var(--ink);
    animation: brutalist-pulse 1.4s ease-in-out infinite;
    height: 16px;
    margin: 8px 0;
}

.skel.h-lg {
    height: 32px;
}

.skel.h-xl {
    height: 48px;
}

.skel.w-half {
    width: 50%;
}

.skel.w-third {
    width: 33%;
}

.skel-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.skel-stat {
    height: 110px;
    border: 2px solid var(--ink);
    background: var(--cream-soft);
    animation: brutalist-pulse 1.4s ease-in-out infinite;
    box-shadow: var(--shadow-hard);
}

.skel-card {
    height: 220px;
    border: 2px solid var(--ink);
    background: var(--cream-soft);
    animation: brutalist-pulse 1.4s ease-in-out infinite;
    box-shadow: var(--shadow-hard);
}

/* Spinner — used for inline loading where skeleton doesn't fit */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid var(--ink);
    border-top-color: var(--yellow);
    border-radius: 0;
    animation: spin 800ms linear infinite;
    vertical-align: middle;
}

/* Smaller variant for inline use inside buttons (e.g. submit while loading). */
.spinner-sm {
    width: 13px;
    height: 13px;
    border-width: 2px;
    /* On colored buttons (primary/danger) the bg is dark, so flip the
       arc color to the cream background and keep the rest light. */
    border-color: rgba(255, 253, 246, 0.35);
    border-top-color: var(--paper);
}

.btn-ghost .spinner-sm,
.btn-accent .spinner-sm {
    border-color: rgba(15, 15, 15, 0.20);
    border-top-color: var(--ink);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px;
    color: var(--ink-soft);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
}

/* Scrollbar */
*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: var(--cream);
}

*::-webkit-scrollbar-thumb {
    background: var(--ink);
    border: 2px solid var(--cream);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--teal);
}