/* ════════════════════════════════════════════════════════════════
   The 100's — Cockpit Premium Design System
   ────────────────────────────────────────────────────────────────
   Brand tokens: cream/gold/charcoal, 0px border-radius, warm-brown
   shadows, slow deliberate animations, premium editorial feel.
   ════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────── */
:root {
    /* Cream tones (warm whites) */
    --cream:        #F8F4ED;   /* main bg */
    --cream-2:      #F1EADC;   /* card subtle bg */
    --cream-3:      #E8DEC9;   /* divider */
    --paper:        #FFFFFF;   /* clean white card */

    /* Gold (Pantone 871C — accent canónico) */
    --gold:         #C9A96E;
    --gold-light:   #E0C992;
    --gold-soft:    rgba(201, 169, 110, 0.10);
    --gold-mid:     rgba(201, 169, 110, 0.20);
    --gold-dark:    #A88A55;

    /* Charcoal */
    --ink:          #1F1F1E;   /* deep ink, not pure black */
    --ink-2:        #2C2C2C;
    --ink-3:        #4A4744;

    /* Greys (warm) */
    --grey-1:       #6B6258;   /* secondary text */
    --grey-2:       #9A8E7E;   /* tertiary */
    --grey-line:    #DDD3BF;   /* hairline */

    /* Status (muted, sophisticated) */
    --warn:         #B07B2C;
    --danger:       #A14C3C;
    --success:      #5C7A52;
    --info:         #3F5566;

    /* Shadows (warm dark-brown rgba) */
    --shadow-xs:    0 1px 2px rgba(92, 61, 46, 0.04);
    --shadow-sm:    0 2px 6px rgba(92, 61, 46, 0.06);
    --shadow-md:    0 6px 20px rgba(92, 61, 46, 0.08);
    --shadow-lg:    0 12px 40px rgba(92, 61, 46, 0.10);

    /* Spacing — 4px base */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
    --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

    /* Type scale */
    --display:    clamp(36px, 4vw, 48px);
    --h1:         32px;
    --h2:         20px;
    --h3:         14px;
    --body:       14px;
    --small:      12px;
    --tiny:       11px;
    --eyebrow:    10px;

    /* Sidebar */
    --sidebar-bg: #1A1715;
    --sidebar-w:  256px;
}

/* ── Reset & Base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-weight: 400;
    font-size: var(--body);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
}

a { color: var(--ink); text-decoration: none; transition: color 200ms ease; }
a:hover { color: var(--gold-dark); }

::selection { background: var(--gold-mid); color: var(--ink); }

/* ── App Shell ──────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--cream);
    padding: var(--s-6) 0 var(--s-4);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(201, 169, 110, 0.15); }

.brand {
    padding: 0 var(--s-5) var(--s-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: var(--s-5);
}

.brand-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 22px;
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--cream);
    margin: 0;
}

.brand-subtitle {
    font-size: var(--tiny);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 6px 0 0;
    font-weight: 500;
}

/* Sidebar nav (flat, focado) */
.nav-pages-flat {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-pages-flat li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    font-size: 13px;
    color: rgba(248, 244, 237, 0.62);
    transition: all 220ms ease;
    border-left: 2px solid transparent;
    letter-spacing: 0.005em;
}

.nav-pages-flat li a:hover {
    color: var(--gold-light);
    background: rgba(255, 255, 255, 0.02);
}

.nav-pages-flat li a.active {
    color: var(--gold);
    background: rgba(201, 169, 110, 0.06);
    border-left-color: var(--gold);
}

.nav-pages-flat .ico {
    display: inline-block;
    width: 18px;
    text-align: center;
    opacity: 0.7;
    font-size: 13px;
}
.nav-pages-flat li a.active .ico { opacity: 1; }

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.04);
    margin: var(--s-3) var(--s-5);
}

/* Sidebar status banners */
.test-banner, .ap-banner {
    margin: 0 var(--s-4) var(--s-4);
    padding: 10px 12px;
    font-size: var(--tiny);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    border-left: 2px solid;
}

.test-banner {
    background: rgba(176, 123, 44, 0.10);
    border-color: var(--warn);
    color: #DDB373;
}
.test-banner .test-email {
    margin-top: 4px;
    font-size: 10px;
    color: rgba(248, 244, 237, 0.55);
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
    word-break: break-all;
}

.ap-banner {
    background: rgba(201, 169, 110, 0.08);
    border-color: var(--gold);
    color: var(--gold-light);
    position: relative;
}
.ap-banner::before {
    content: '';
    position: absolute;
    left: -2px; top: 0; bottom: 0; width: 2px;
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold);
    animation: pulse 2.4s ease-in-out infinite;
}
.ap-banner .ap-detail {
    margin-top: 4px;
    font-size: 10px;
    color: rgba(248, 244, 237, 0.50);
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
}
@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--gold); }
    50%      { opacity: 0.4; box-shadow: 0 0 2px var(--gold); }
}

/* ── Main ───────────────────────────────────────── */
.main {
    padding: var(--s-10) var(--s-12) var(--s-16);
    max-width: 1320px;
    width: 100%;
    animation: fade-up 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Page header / topbar ───────────────────────── */
.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-6);
    padding-bottom: var(--s-6);
    margin-bottom: var(--s-8);
    border-bottom: 1px solid var(--grey-line);
}

.topbar-left { flex: 1; min-width: 0; }

.crumbs {
    font-size: var(--tiny);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--grey-2);
    margin-bottom: var(--s-2);
    display: flex;
    align-items: center;
    gap: 8px;
}
.crumbs a { color: var(--grey-1); transition: color 200ms ease; }
.crumbs a:hover { color: var(--gold-dark); }
.crumbs .sep { color: var(--grey-line); font-size: 10px; }

.topbar-right {
    display: flex;
    gap: var(--s-3);
    align-items: center;
    flex-shrink: 0;
}

/* ── Typography ─────────────────────────────────── */
h1, h2, h3, h4 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--ink);
    font-weight: 400;
    margin: 0;
    line-height: 1.15;
    letter-spacing: -0.015em;
}

h1 {
    font-size: var(--h1);
    font-weight: 400;
}

h2 {
    font-size: var(--h2);
    margin-top: var(--s-10);
    margin-bottom: var(--s-4);
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--grey-line);
}

h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: var(--h3);
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--grey-1);
    margin-top: var(--s-6);
    margin-bottom: var(--s-3);
}

.tagline, .subtitle {
    color: var(--grey-1);
    font-size: 15px;
    line-height: 1.55;
    margin: 8px 0 0;
    font-weight: 400;
    max-width: 60ch;
}

.eyebrow {
    font-size: var(--eyebrow);
    letter-spacing: 0.20em;
    text-transform: uppercase;
    color: var(--gold-dark);
    font-weight: 600;
    margin: 0 0 8px;
}

/* ── KPIs ───────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--s-4);
    margin: var(--s-6) 0 var(--s-8);
}

.kpi {
    background: var(--paper);
    padding: var(--s-5) var(--s-5) var(--s-6);
    border: 1px solid var(--grey-line);
    box-shadow: var(--shadow-xs);
    transition: transform 350ms cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 350ms cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 32px; height: 2px;
    background: var(--gold);
}

.kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi .label {
    font-size: var(--tiny);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--grey-1);
    font-weight: 600;
}

.kpi .value {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 36px;
    font-weight: 400;
    color: var(--ink);
    margin-top: 12px;
    letter-spacing: -0.02em;
    line-height: 1;
}

.kpi .unit {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--grey-1);
    margin-left: 6px;
    font-weight: 400;
}

.kpi .delta {
    font-size: var(--tiny);
    color: var(--grey-2);
    margin-top: 6px;
}

/* ── Tables ─────────────────────────────────────── */
.table-wrap {
    background: var(--paper);
    border: 1px solid var(--grey-line);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    margin: var(--s-4) 0 var(--s-6);
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* Standalone table outside .table-wrap */
.main > table {
    background: var(--paper);
    border: 1px solid var(--grey-line);
    box-shadow: var(--shadow-xs);
    margin: var(--s-4) 0 var(--s-6);
}

th, td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--grey-line);
    font-size: var(--body);
    line-height: 1.4;
}

th {
    background: var(--cream-2);
    font-size: var(--eyebrow);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--grey-1);
    border-bottom: 1px solid var(--gold);
    padding-top: 14px;
    padding-bottom: 14px;
}

tbody tr {
    transition: background 180ms ease;
}
tbody tr:hover { background: rgba(201, 169, 110, 0.04); }
tbody tr:last-child td { border-bottom: 0; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--grey-1); }
td.warn  { color: var(--warn); font-weight: 600; }
td.danger { color: var(--danger); font-weight: 600; }
td.code, .code {
    font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    letter-spacing: 0;
}

tfoot td {
    background: var(--cream-2);
    font-weight: 600;
    border-top: 2px solid var(--gold);
    border-bottom: 0;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--cream);
    font-family: inherit;
    font-size: var(--small);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    font-weight: 600;
    cursor: pointer;
    transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 0;
    text-decoration: none;
    line-height: 1;
}

.btn:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--ink);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--ink);
}
.btn-primary:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
    color: var(--cream);
}

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--grey-line);
}
.btn-ghost:hover {
    background: var(--ink);
    color: var(--cream);
    border-color: var(--ink);
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: var(--cream);
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--eyebrow);
    letter-spacing: 0.12em;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 13px;
}

.btn-row {
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
    margin: var(--s-4) 0;
    align-items: center;
}

/* ── Forms ──────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="password"],
input[type="search"],
select,
textarea {
    font-family: inherit;
    font-size: var(--body);
    padding: 10px 12px;
    background: var(--paper);
    border: 1px solid var(--grey-line);
    color: var(--ink);
    width: 100%;
    border-radius: 0;
    transition: border-color 220ms ease, box-shadow 220ms ease;
    line-height: 1.4;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

input[type="number"] {
    font-variant-numeric: tabular-nums;
}

label.field {
    display: block;
    margin-bottom: var(--s-4);
}

label.field > span {
    display: block;
    font-size: var(--tiny);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--grey-1);
    margin-bottom: 6px;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 var(--s-6);
}

/* ── Alerts ─────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    margin: var(--s-3) 0;
    border-left: 3px solid var(--info);
    background: var(--paper);
    font-size: var(--body);
    border-top: 1px solid var(--grey-line);
    border-right: 1px solid var(--grey-line);
    border-bottom: 1px solid var(--grey-line);
    box-shadow: var(--shadow-xs);
}
.alert.warn    { border-left-color: var(--warn); }
.alert.danger  { border-left-color: var(--danger); }
.alert.success { border-left-color: var(--success); }

.callout {
    background: linear-gradient(180deg, var(--gold-soft), transparent);
    border-left: 3px solid var(--gold);
    padding: 16px 20px;
    font-size: var(--body);
    margin: var(--s-4) 0;
}
.callout strong { color: var(--gold-dark); }
.callout ol, .callout ul { margin: 8px 0 0; padding-left: 20px; }

/* ── Status pills ───────────────────────────────── */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: var(--eyebrow);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid currentColor;
    line-height: 1.4;
}
.status::before {
    content: '';
    width: 6px; height: 6px;
    background: currentColor;
    display: inline-block;
}
.status.draft, .status.pending, .status.planned { color: var(--grey-1); }
.status.pending_approval, .status.wip { color: var(--warn); }
.status.sent, .status.info { color: var(--info); }
.status.confirmed, .status.delivered, .status.active, .status.success { color: var(--success); }
.status.cancelled, .status.danger { color: var(--danger); }

/* ── Cards / Sections ──────────────────────────── */
.card {
    background: var(--paper);
    border: 1px solid var(--grey-line);
    padding: var(--s-6);
    box-shadow: var(--shadow-xs);
    margin: var(--s-4) 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--s-4);
}

.section-card {
    background: var(--paper);
    padding: var(--s-5);
    border: 1px solid var(--grey-line);
    transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--gold);
}

/* ── Stub / detail block ────────────────────────── */
.stub {
    background: var(--paper);
    padding: var(--s-6);
    border: 1px solid var(--grey-line);
    margin: var(--s-4) 0;
    box-shadow: var(--shadow-xs);
}

/* ── Util ───────────────────────────────────────── */
.muted { color: var(--grey-1); }
.tnum  { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.flex { display: flex; gap: var(--s-3); align-items: center; }
.spacer { flex-grow: 1; }
.space-between { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); }
.mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }
.hidden { display: none; }
.no-wrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hr { height: 1px; background: var(--grey-line); margin: var(--s-8) 0; border: 0; }

/* Small inline pill (count badge) */
.count-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    background: var(--gold-soft);
    color: var(--gold-dark);
    font-size: var(--tiny);
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* Linked code (clickable code badge) */
a.code-link {
    color: var(--gold-dark);
    border-bottom: 1px dotted var(--gold-soft);
    transition: all 200ms ease;
}
a.code-link:hover {
    color: var(--ink);
    border-color: var(--gold);
}

/* Chip (filter / facet) */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--cream-2);
    color: var(--grey-1);
    border: 1px solid var(--grey-line);
    font-size: var(--small);
    letter-spacing: 0.04em;
    text-decoration: none;
    transition: all 200ms ease;
}
.chip:hover { color: var(--ink); border-color: var(--gold); }
.chip.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* Empty state */
.empty {
    padding: var(--s-12) var(--s-6);
    text-align: center;
    color: var(--grey-1);
    font-size: 15px;
    background: var(--paper);
    border: 1px dashed var(--grey-line);
    margin: var(--s-4) 0;
}
.empty .icon {
    font-size: 32px;
    opacity: 0.4;
    display: block;
    margin: 0 auto 12px;
}

/* Bar / progress */
.bar {
    height: 4px;
    background: var(--grey-line);
    overflow: hidden;
    margin-top: 6px;
}
.bar > span {
    display: block;
    height: 100%;
    background: var(--gold);
    transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.bar.danger > span { background: var(--danger); }
.bar.warn > span { background: var(--warn); }
.bar.success > span { background: var(--success); }

/* Definition list (key-value vertical) */
dl.dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 10px var(--s-6);
    margin: 0;
}
dl.dl dt {
    font-size: var(--tiny);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--grey-1);
    font-weight: 600;
}
dl.dl dd {
    margin: 0;
    color: var(--ink);
    font-size: var(--body);
}

/* Print-style for emails preview */
.preview {
    background: var(--paper);
    border: 1px solid var(--grey-line);
    padding: var(--s-8);
    box-shadow: var(--shadow-md);
    margin: var(--s-4) 0;
}

/* Responsive */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: var(--s-6) var(--s-4) var(--s-10); }
    .form-grid { grid-template-columns: 1fr; }
}
