/* ===========================================================
   SMFlow — Smith Media Light Theme
   Clean affiliate-tracker interface inspired by modern
   analytics dashboards.

   IMPORTANT:
   Existing class names are preserved.
   =========================================================== */

:root {
    /* Main surfaces */
    --bg:             #F5F7FA;
    --surface:        #FFFFFF;
    --surface-raised: #F8FAFC;
    --border:         #E3E7ED;

    /* Text */
    --text:           #20242B;
    --text-dim:       #667085;
    --text-faint:     #98A2B3;

    /* Smith Media primary accent */
    --amber:          #C9161D;
    --amber-dim:      #8D2025;

    /* Financial / system states */
    --positive:       #169B62;
    --negative:       #D92D3A;

    /* UI */
    --radius-sm: 5px;
    --radius-md: 7px;

    /* Fonts */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}


/* ===========================================================
   GLOBAL
   =========================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--amber);
    text-decoration: none;
}

a:hover {
    color: #A91218;
    text-decoration: none;
}


/* ===========================================================
   APP SHELL
   =========================================================== */

.app-shell {
    display: grid;
    grid-template-columns: 216px 1fr;
    min-height: 100vh;
}


/* ===========================================================
   SIDEBAR
   =========================================================== */

.sidebar {
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}


/* ---------- Brand ---------- */

.sidebar__brand {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 19px;
    letter-spacing: 0.06em;

    background: linear-gradient(
        115deg,
        #E2161D 0%,
        #C9161D 35%,
        #8B3035 65%,
        #45464D 100%
    );

    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;

    padding: 0 20px 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;

    text-transform: uppercase;
}

.sidebar__brand span {
    color: inherit;
}


/* ---------- Navigation groups ---------- */

.nav-group {
    margin-bottom: 18px;
}

.nav-group__label {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-faint);
    padding: 0 20px 7px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}


/* ---------- Navigation links ---------- */

.nav-link {
    display: block;
    padding: 8px 20px;
    color: var(--text-dim);
    font-size: 13.5px;
    border-left: 3px solid transparent;
    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.nav-link:hover {
    color: var(--amber);
    text-decoration: none;
    background: #F8F9FB;
}

.nav-link.active {
    color: var(--amber);
    font-weight: 600;
    border-left-color: var(--amber);
    background: #FFF4F4;
}


/* ===========================================================
   MAIN
   =========================================================== */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}


/* ===========================================================
   TOPBAR
   =========================================================== */

.topbar {
    height: 56px;
    border-bottom: 1px solid #30343B;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;

    background: linear-gradient(
        90deg,
        #17191E 0%,
        #22252B 65%,
        #382126 100%
    );

    color: #FFFFFF;
}


/* ---------- Date range ---------- */

.topbar__daterange {
    font-family: var(--font-mono);
    font-size: 12.5px;

    color: #F2F4F7;
    background: rgba(255, 255, 255, 0.08);

    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm);

    padding: 6px 12px;
}


/* ---------- User ---------- */

.topbar__user {
    color: #F2F4F7;
    font-size: 13px;
}

.topbar__user a {
    color: #D0D5DD;
    margin-left: 12px;
}

.topbar__user a:hover {
    color: #FFFFFF;
}


/* ===========================================================
   CONTENT
   =========================================================== */

.content {
    padding: 24px;
    flex: 1;
    background: var(--bg);
}


/* ===========================================================
   KPI CARDS
   =========================================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}


.kpi-card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;

    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.025),
        0 1px 4px rgba(16, 24, 40, 0.025);
}


.kpi-card__label {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-faint);
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}


.kpi-card__value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
}


.kpi-card__delta {
    font-family: var(--font-mono);
    font-size: 11.5px;
    margin-top: 6px;
}


.kpi-card__delta.up {
    color: var(--positive);
}

.kpi-card__delta.down {
    color: var(--negative);
}

.kpi-card__delta.flat {
    color: var(--text-faint);
}


/* ===========================================================
   PANELS
   =========================================================== */

.panel {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;

    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.02),
        0 1px 4px rgba(16, 24, 40, 0.02);
}


.panel__header {
    padding: 13px 16px;

    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;
    justify-content: space-between;

    background: #FFFFFF;
}


.panel__title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}


.panel__body {
    padding: 0;
}


/* ===========================================================
   DATA TABLES
   =========================================================== */

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}


table.data-table th {
    text-align: left;

    font-size: 11px;
    font-weight: 600;

    color: var(--text-faint);
    letter-spacing: 0.03em;

    padding: 10px 16px;

    border-bottom: 1px solid var(--border);

    position: sticky;
    top: 0;

    background: #F8FAFC;
}


table.data-table td {
    padding: 10px 16px;

    border-bottom: 1px solid #EEF1F4;

    font-family: var(--font-mono);

    color: var(--text);

    white-space: nowrap;

    background: #FFFFFF;
}


table.data-table td.text {
    font-family: var(--font-ui);
}


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


table.data-table tr:hover td {
    background: #FAFBFC;
}


.num-positive {
    color: var(--positive);
}


.num-negative {
    color: var(--negative);
}


/* ===========================================================
   EMPTY STATES
   =========================================================== */

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-dim);
}


.empty-state__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}


.empty-state__body {
    font-size: 13px;
    color: var(--text-faint);
    max-width: 420px;
    margin: 0 auto;
}


/* ===========================================================
   SYSTEM HEALTH
   =========================================================== */

.health-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}


.health-item {
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);

    padding: 10px 12px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    font-size: 12.5px;
}


.health-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    display: inline-block;

    margin-right: 7px;
}


.health-dot.ok {
    background: var(--positive);
}


.health-dot.warn {
    background: #F59E0B;
}


.health-dot.bad {
    background: var(--negative);
}


/* ===========================================================
   LOGIN
   =========================================================== */

.login-wrap {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #F5F7FA;
}


.login-card {
    width: 340px;

    background: #FFFFFF;

    border: 1px solid var(--border);
    border-radius: 8px;

    padding: 28px;

    box-shadow:
        0 4px 8px rgba(16, 24, 40, 0.04),
        0 12px 28px rgba(16, 24, 40, 0.06);
}


.login-card__brand {
    font-family: var(--font-mono);

    font-size: 17px;
    font-weight: 700;

    margin-bottom: 20px;

    color: var(--text);
}


.login-card__brand span {
    color: var(--amber);
}


/* ===========================================================
   FIELDS
   =========================================================== */

.field {
    margin-bottom: 14px;
}


.field label {
    display: block;

    font-size: 12px;
    font-weight: 500;

    color: var(--text-dim);

    margin-bottom: 5px;
}


.field input {
    width: 100%;

    background: #FFFFFF;

    border: 1px solid #D0D5DD;
    border-radius: var(--radius-sm);

    padding: 9px 10px;

    color: var(--text);

    font-size: 13.5px;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.field input:focus {
    outline: none;

    border-color: var(--amber);

    box-shadow:
        0 0 0 3px rgba(201, 22, 29, 0.08);
}


/* ===========================================================
   BUTTONS
   =========================================================== */

.btn {
    display: inline-block;

    background: var(--amber);

    color: #FFFFFF;

    border: none;
    border-radius: var(--radius-sm);

    padding: 9px 14px;

    font-size: 13.5px;
    font-weight: 600;

    cursor: pointer;

    width: 100%;

    transition:
        background-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.05s ease;
}


.btn:hover {
    background: #A91218;
}


.btn:active {
    transform: translateY(1px);
}


/* ===========================================================
   FORM ERRORS
   =========================================================== */

.form-error {
    background: #FFF1F2;

    border: 1px solid #FECDD3;

    color: var(--negative);

    border-radius: var(--radius-sm);

    padding: 9px 11px;

    font-size: 12.5px;

    margin-bottom: 14px;
}


/* ===========================================================
   GENERIC CRUD FORMS
   =========================================================== */

.form-grid {
    display: grid;

    grid-template-columns: repeat(2, 1fr);

    gap: 14px;

    padding: 16px;
}


.form-grid .field.full {
    grid-column: 1 / -1;
}


.field select,
.field textarea {
    width: 100%;

    background: #FFFFFF;

    border: 1px solid #D0D5DD;
    border-radius: var(--radius-sm);

    padding: 9px 10px;

    color: var(--text);

    font-size: 13.5px;

    font-family: var(--font-ui);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.field textarea {
    font-family: var(--font-mono);
    font-size: 12.5px;
    resize: vertical;
}


.field select:focus,
.field textarea:focus {
    outline: none;

    border-color: var(--amber);

    box-shadow:
        0 0 0 3px rgba(201, 22, 29, 0.08);
}


.field__hint {
    font-size: 11.5px;

    color: var(--text-faint);

    margin-top: 4px;
}


/* ===========================================================
   FORM ACTIONS
   =========================================================== */

.form-actions {
    padding: 12px 16px;

    border-top: 1px solid var(--border);

    display: flex;

    gap: 10px;

    background: #FAFBFC;
}


/* ===========================================================
   SECONDARY BUTTON
   =========================================================== */

.btn-secondary {
    display: inline-block;

    background: #FFFFFF;

    color: var(--text-dim);

    border: 1px solid #D0D5DD;
    border-radius: var(--radius-sm);

    padding: 9px 14px;

    font-size: 13px;

    cursor: pointer;

    text-decoration: none;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}


.btn-secondary:hover {
    color: var(--text);

    background: #F8FAFC;

    border-color: #98A2B3;

    text-decoration: none;
}


.btn-inline {
    width: auto;
    padding: 8px 14px;
}


/* ===========================================================
   DANGER LINKS
   =========================================================== */

.btn-danger-link {
    color: var(--negative);

    background: none;

    border: none;

    padding: 0;

    font-size: 12.5px;

    cursor: pointer;
}


.btn-danger-link:hover {
    color: #B4232F;
    text-decoration: underline;
}


.panel__header .btn-inline {
    width: auto;
}


/* ===========================================================
   BADGES
   =========================================================== */

.badge {
    display: inline-block;

    font-size: 11px;
    font-weight: 500;

    padding: 3px 8px;

    border-radius: 12px;

    font-family: var(--font-ui);
}


.badge.active {
    background: #ECFDF3;
    color: var(--positive);
}


.badge.paused {
    background: #FFF4F4;
    color: var(--amber);
}


.badge.archived {
    background: #F2F4F7;
    color: var(--text-dim);
}


.badge.error {
    background: #FFF1F2;
    color: var(--negative);
}


.badge.pending {
    background: #F2F4F7;
    color: var(--text-dim);
}


/* ===========================================================
   ROW ACTIONS
   =========================================================== */

.row-actions a,
.row-actions button {
    margin-right: 10px;
    font-size: 12.5px;
}


/* ===========================================================
   COPY URL
   =========================================================== */

.copy-url {
    font-family: var(--font-mono);

    font-size: 12px;

    background: #F8FAFC;

    border: 1px solid var(--border);

    border-radius: var(--radius-sm);

    padding: 6px 9px;

    color: var(--text-dim);

    display: inline-flex;

    align-items: center;

    gap: 8px;
}


.copy-url button {
    background: none;

    border: none;

    color: var(--amber);

    cursor: pointer;

    font-size: 11px;

    font-family: var(--font-ui);
}


.copy-url button:hover {
    color: #A91218;
}