* {
    box-sizing: border-box;
}

:root {
    --bg:     #f8fafc;
    --bg2:    #f1f5f9;
    --card:   #ffffff;
    --text:   #1e293b;
    --muted:  #64748b;
    --border: rgba(15, 23, 42, .08);

    /* Acento roxo/violeta (mantém nomes --blue p/ compatibilidade) */
    --blue:   #7c3aed;
    --blue2:  #6d28d9;
    --violet: #7c3aed;
    --violet-soft: #ede9fe;
    --violet-text: #5b21b6;

    --green:  #059669;
    --red:    #dc2626;
    --yellow: #d97706;

    --shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 20px rgba(15, 23, 42, .04);
    --shadow-hover: 0 4px 12px rgba(124, 58, 237, .08), 0 12px 32px rgba(15, 23, 42, .08);
}

html, body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: linear-gradient(160deg, #f1f5f9 0%, #e8eef5 100%);
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(15,23,42,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15,23,42,.03) 1px, transparent 1px);
    background-size: 42px 42px;
    pointer-events: none;
    z-index: -1;
}

a {
    color: inherit;
    text-decoration: none;
}

/* -- Header --------------------------------------------------------------- */

.top {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 72px;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 6px rgba(15, 23, 42, .06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand img {
    height: 44px;
    max-width: 180px;
    object-fit: contain;
}

.brand b {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

/* -- Layout --------------------------------------------------------------- */

.wrap {
    max-width: 1240px;
    margin: 32px auto;
    padding: 0 22px;
}

/* -- Cards ---------------------------------------------------------------- */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.form-card {
    max-width: 860px;
    margin: 0 auto;
}

/* -- Typography ----------------------------------------------------------- */

.title {
    margin: 0 0 10px;
    font-size: clamp(24px, 4vw, 34px);
    letter-spacing: -0.04em;
    line-height: 1.08;
    color: var(--text);
}

h1, h2, h3 {
    letter-spacing: -0.03em;
    color: var(--text);
}

h2 {
    margin-top: 0;
}

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

/* -- Grid ----------------------------------------------------------------- */

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

/* -- Fields --------------------------------------------------------------- */

.field label {
    display: block;
    margin-bottom: 7px;
    color: #475569;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.field input,
.field select,
.field textarea,
.searchbar input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 12px 14px;
    font-size: 15px;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.searchbar input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}

.field input[readonly] {
    background: #f8fafc;
    color: #475569;
    cursor: default;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

/* -- Buttons --------------------------------------------------------------- */

.btn {
    border: 0;
    border-radius: 999px;
    min-height: 42px;
    padding: 10px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    transition: .16s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn:active {
    transform: translateY(0);
    filter: brightness(.96);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed, #6d28d9);
    box-shadow: 0 4px 14px rgba(124,58,237,.28);
}

.btn-light {
    color: #334155;
    background: #fff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(15,23,42,.06);
}

.btn-light:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-danger {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* -- Actions --------------------------------------------------------------- */

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

/* -- KPIs ------------------------------------------------------------------ */

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.kpi {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    top: 0; right: 0;
    width: 56px; height: 56px;
    background: radial-gradient(circle at top right, rgba(124,58,237,.10), transparent 70%);
    pointer-events: none;
}

.kpi small {
    position: relative;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.kpi b {
    position: relative;
    display: block;
    margin-top: 5px;
    font-size: 22px;
    line-height: 1;
    letter-spacing: -0.05em;
    color: var(--text);
}

/* -- Table ----------------------------------------------------------------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 10px;
}

.table {
    width: 100%;
    min-width: 820px;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table th {
    padding: 0 14px 4px;
    text-align: left;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
}

.table td {
    padding: 14px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: var(--text);
}

.table td:first-child {
    border-left: 1px solid #f1f5f9;
    border-radius: 14px 0 0 14px;
}

.table td:last-child {
    border-right: 1px solid #f1f5f9;
    border-radius: 0 14px 14px 0;
}

.table tr:hover td {
    background: #f8fafc;
    border-color: #e2e8f0;
}

/* -- Badges ---------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-new {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.badge-ok {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-blue {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
}

/* -- Notice ---------------------------------------------------------------- */

.notice {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #6d28d9;
    font-size: 14px;
    line-height: 1.55;
}

/* -- Tabs ------------------------------------------------------------------ */

.tabs {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 5px;
}

.tab {
    flex: 1;
    padding: 11px 16px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: .18s;
}

.tab.active {
    background: #fff;
    color: var(--text);
    box-shadow: 0 1px 6px rgba(15,23,42,.10);
}

/* -- Photo ----------------------------------------------------------------- */

.photo-row {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.photo-box {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
    border-radius: 18px;
    overflow: hidden;
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-box img,
.photo-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-placeholder {
    font-size: 64px;
    opacity: .4;
}

.photo-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* -- Switch ---------------------------------------------------------------- */

.switch {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--text);
    font-size: 14px;
}

.switch input {
    width: 40px;
    height: 22px;
    accent-color: var(--blue);
    cursor: pointer;
}

/* -- Login ----------------------------------------------------------------- */

.login {
    max-width: 420px;
    margin: 72px auto;
    padding: 0 16px;
}

.login .card {
    padding: 36px;
    border-radius: 24px;
    box-shadow: 0 8px 40px rgba(15,23,42,.12);
}

/* -- Success --------------------------------------------------------------- */

.success {
    max-width: 580px;
    text-align: center;
    margin: 72px auto;
}

.success .check {
    font-size: 60px;
}

/* -- Linkbox --------------------------------------------------------------- */

.linkbox {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    word-break: break-all;
    color: var(--muted);
    font-size: 13px;
}

/* -- Search / Filters ------------------------------------------------------ */

.searchbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.searchbar input {
    flex: 1;
}

.filtros-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 16px 0 8px;
}

.filtro-select {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color .18s, box-shadow .18s;
}

.filtro-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}

/* -- Utils ----------------------------------------------------------------- */

.hidden {
    display: none !important;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* -- Responsive 768px ------------------------------------------------------ */

@media (max-width: 768px) {
    .top {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .wrap {
        margin: 18px auto;
        padding: 0 12px;
    }

    .card {
        padding: 18px;
        border-radius: 18px;
    }

    .grid {
        display: block;
    }

    .col-12,
    .col-8,
    .col-6,
    .col-4,
    .col-3 {
        margin-bottom: 14px;
    }

    .kpis {
        gap: 10px;
    }

    .kpi {
        padding: 11px;
        border-radius: 12px;
    }

    .kpi b {
        font-size: 20px;
    }

    .tabs {
        flex-direction: column;
        border-radius: 18px;
    }

    .photo-row {
        flex-direction: column;
    }

    .photo-box {
        width: 100%;
        height: 240px;
    }

    .photo-actions {
        width: 100%;
    }

    .btn,
    .photo-actions .btn {
        width: 100%;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .searchbar {
        flex-direction: column;
    }

    .filtros-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filtro-select {
        width: 100%;
    }

    .hide-mobile {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   TEMA ESCURO
   -------------------------------------------------------------------------- */

[data-theme="dark"] {
    --bg:     #05070d;
    --bg2:    #0b0f19;
    --card:   #0f1724;
    --text:   #f0f6ff;
    --muted:  #94a3b8;
    --border: rgba(148, 163, 184, .16);
    --blue:   #a78bfa;
    --blue2:  #8b5cf6;
    --shadow: 0 8px 40px rgba(0, 0, 0, .45);
}

[data-theme="dark"] html,
[data-theme="dark"] body,
html[data-theme="dark"],
html[data-theme="dark"] body {
    background: linear-gradient(160deg, #05070d 0%, #0b0f19 100%);
    color: var(--text);
}

html[data-theme="dark"] body::before {
    background-image:
        linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
}

/* Header */
html[data-theme="dark"] .top {
    background: rgba(5, 7, 13, .88);
    box-shadow: 0 1px 0 rgba(148,163,184,.10);
}

/* Cards */
html[data-theme="dark"] .card {
    background: linear-gradient(160deg, #0f1724, #0a1120);
}

/* KPIs */
html[data-theme="dark"] .kpi {
    background: linear-gradient(160deg, #111c2d, #0b1220);
}

/* Inputs */
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .searchbar input {
    background: #07111f;
    border-color: rgba(148,163,184,.22);
    color: var(--text);
}

html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .field select:focus,
html[data-theme="dark"] .field textarea:focus,
html[data-theme="dark"] .searchbar input:focus {
    background: #0a1628;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}

html[data-theme="dark"] .field input[readonly] {
    background: #060e1a;
    color: #94a3b8;
}

html[data-theme="dark"] .field label {
    color: #94a3b8;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #475569;
}

/* Buttons */
html[data-theme="dark"] .btn-light {
    background: rgba(15, 23, 42, .85);
    color: #e2e8f0;
    border-color: rgba(148,163,184,.24);
}

html[data-theme="dark"] .btn-light:hover {
    background: rgba(30, 41, 59, .90);
    border-color: rgba(148,163,184,.40);
}

html[data-theme="dark"] .btn-danger {
    background: rgba(127,29,29,.45);
    color: #fca5a5;
    border-color: rgba(239,68,68,.30);
}

html[data-theme="dark"] .btn-danger:hover {
    background: rgba(153,27,27,.60);
}

/* Tabs */
html[data-theme="dark"] .tabs {
    background: rgba(7,17,31,.80);
}

html[data-theme="dark"] .tab {
    color: #94a3b8;
    background: transparent;
}

html[data-theme="dark"] .tab.active {
    background: #0f1f36;
    color: #f0f6ff;
    box-shadow: 0 1px 6px rgba(0,0,0,.30);
}

/* Table */
html[data-theme="dark"] .table td {
    background: rgba(10, 17, 32, .90);
    border-color: rgba(148,163,184,.10);
    color: var(--text);
}

html[data-theme="dark"] .table td:first-child,
html[data-theme="dark"] .table td:last-child {
    border-color: rgba(148,163,184,.10);
}

html[data-theme="dark"] .table tr:hover td {
    background: rgba(20, 30, 50, .95);
}

html[data-theme="dark"] .table th {
    color: #64748b;
}

/* Badges */
html[data-theme="dark"] .badge-new {
    background: rgba(239,68,68,.18);
    color: #fca5a5;
    border-color: rgba(239,68,68,.22);
}

html[data-theme="dark"] .badge-ok {
    background: rgba(34,197,94,.14);
    color: #86efac;
    border-color: rgba(34,197,94,.22);
}

html[data-theme="dark"] .badge-blue {
    background: rgba(56,189,248,.14);
    color: #7dd3fc;
    border-color: rgba(56,189,248,.22);
}

/* Notice */
html[data-theme="dark"] .notice {
    background: rgba(124,58,237,.10);
    border-color: rgba(56,189,248,.22);
    color: #bae6fd;
}

/* Photo box */
html[data-theme="dark"] .photo-box {
    background: #0a1628;
    border-color: rgba(148,163,184,.20);
    border-style: dashed;
}

/* Linkbox */
html[data-theme="dark"] .linkbox {
    background: #07111f;
    border-color: rgba(148,163,184,.24);
}

/* Filtros */
html[data-theme="dark"] .filtro-select {
    background: #07111f;
    border-color: rgba(148,163,184,.22);
    color: var(--text);
}

html[data-theme="dark"] .filtro-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}

/* -------------------------------------------------------------------------- */

/* -- Responsive 430px ------------------------------------------------------ */

@media (max-width: 430px) {
    .brand img {
        height: 36px;
        max-width: 140px;
    }

    .title {
        font-size: 23px;
    }

    .photo-box {
        height: 210px;
    }

    .table {
        min-width: 720px;
    }
}