/* ─────────────────────────────────────────
   Design tokens
───────────────────────────────────────── */
:root {
    --blue-600:  #026AB1;   /* brand primary */
    --blue-700:  #015a97;
    --blue-800:  #014a7c;
    --blue-50:   #e6f2fb;
    --blue-100:  #cce4f7;

    --bg:        #f0f6fc;
    --surface:   #ffffff;
    --text:      #0d1f33;
    --text-body: #3a4a5c;
    --muted:     #6b7d8f;
    --border:    #d3dde8;

    --danger:         #c0392b;
    --danger-dark:    #992d22;
    --danger-bg:      #fdf1f0;
    --danger-border:  #f0c0bc;

    --success:   #1a7a4a;
    --success-bg:#e6f5ed;

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;

    --shadow-sm: 0 1px 3px rgba(2, 106, 177, 0.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 4px 16px rgba(2, 106, 177, 0.10), 0 1px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 32px rgba(2, 106, 177, 0.14), 0 2px 8px rgba(0,0,0,.08);
}

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

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    color: var(--text);
    margin-top: 0;
}

a {
    color: var(--blue-600);
    text-decoration: none;
    transition: color .15s;
}
a:hover { color: var(--blue-700); }

/* ─────────────────────────────────────────
   Topbar / navigation  — dark navy style
───────────────────────────────────────── */
.topbar {
    background: #0d1f33;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 3vw;
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,.40);
}

.topbar nav {
    display: flex;
    align-items: stretch;
    gap: 0;
    height: 100%;
}

/* Logo */
.brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding-right: 36px;
    text-decoration: none;
}

.brand-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* nav links — uppercase, small, tracked */
.topbar nav a {
    display: inline-flex;
    align-items: center;
    color: rgba(255,255,255,.65);
    font-weight: 600;
    font-size: .78rem;
    letter-spacing: .10em;
    text-transform: uppercase;
    padding: 0 20px;
    height: 100%;
    border-bottom: 2px solid transparent;
    border-top: 2px solid transparent;
    transition: color .15s, border-color .15s;
    text-decoration: none;
    white-space: nowrap;
}
.topbar nav a:hover {
    color: #fff;
    border-bottom-color: rgba(255,255,255,.50);
}
.topbar nav a.active {
    color: #fff;
    border-bottom-color: #fff;
}

/* Herramientas de ítems (ventas). */
.nav-items { position: relative; height: 100%; }
.nav-items-trigger {
    display: inline-flex; align-items: center; gap: 6px; height: 100%;
    padding: 0 20px; background: transparent; color: rgba(255,255,255,.65);
    border: 0; border-bottom: 2px solid transparent; border-top: 2px solid transparent;
    border-radius: 0; box-shadow: none; font: inherit; font-size: .78rem;
    font-weight: 600; letter-spacing: .10em; text-transform: uppercase; cursor: pointer;
}
.nav-items-trigger:hover, .nav-items-trigger.active, .nav-items-trigger[aria-expanded="true"] {
    background: transparent; color: #fff; border-bottom-color: #fff;
}
.nav-items-dropdown {
    position: absolute; top: 100%; right: 0; z-index: 200;
    width: max-content; max-width: min(360px, 90vw); padding: 6px;
    background: #fff; border: 1px solid #d3dde8; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(2,106,177,.15);
}
.topbar nav .nav-items-dropdown a {
    display: block; height: auto; padding: 12px; border: 0;
    color: #0d1f33; font-size: .88rem; letter-spacing: normal;
    text-transform: none; white-space: normal; border-radius: 4px;
}
.topbar nav .nav-items-dropdown a:hover,
.topbar nav .nav-items-dropdown a:focus-visible,
.topbar nav .nav-items-dropdown a.active { background: #f0f6fc; color: #026ab1; }

/* user chip */
.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: .82rem;
    font-weight: 500;
    color: rgba(255,255,255,.50);
    padding: 0 18px;
    border-left: 1px solid rgba(255,255,255,.10);
    margin-left: 6px;
    height: 100%;
    white-space: nowrap;
}
.nav-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* logout */
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: rgba(255,255,255,.55);
    border: 1px solid rgba(255,255,255,.20);
    border-radius: 5px;
    padding: 8px 18px;
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
    margin-left: 12px;
    align-self: center;
}
.btn-logout:hover {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}
.btn-logout:active { transform: scale(.97); }

/* ─────────────────────────────────────────
   Layout
───────────────────────────────────────── */
.container {
    width: min(1140px, 92%);
    margin: 40px auto;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
}

.page-heading h1 {
    font-size: 1.65rem;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.page-heading p {
    margin: 0;
    color: var(--muted);
    font-size: .95rem;
}

/* ─────────────────────────────────────────
   Cards
───────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ─────────────────────────────────────────
   Buttons
───────────────────────────────────────── */
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
    white-space: nowrap;
}

button:active, .button:active { transform: scale(.97); }

/* Primary */
.primary {
    background: var(--blue-600);
    color: #fff;
    border-color: var(--blue-600);
    box-shadow: 0 2px 8px rgba(2, 106, 177, 0.30);
}
.primary:hover {
    background: var(--blue-700);
    border-color: var(--blue-700);
    box-shadow: 0 4px 14px rgba(2, 106, 177, 0.35);
}

/* Secondary / outlined */
.secondary {
    background: var(--surface);
    color: var(--blue-600);
    border-color: var(--blue-600);
}
.secondary:hover {
    background: var(--blue-50);
}

/* Ghost / link-style */
.link-button {
    background: transparent;
    color: var(--blue-600);
    border-color: transparent;
    padding: 0;
    font-weight: 500;
    box-shadow: none;
}
.link-button:hover { color: var(--blue-700); }

/* ─────────────────────────────────────────
   Metrics
───────────────────────────────────────── */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--blue-600);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s;
}
.metric-card:hover { box-shadow: var(--shadow); }

.metric-card span {
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.metric-card strong {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
    font-weight: 800;
    color: var(--blue-600);
    letter-spacing: -0.03em;
}

/* ─────────────────────────────────────────
   Table
───────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

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

thead {
    background: var(--blue-50);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    color: var(--blue-700);
    text-transform: uppercase;
    letter-spacing: .07em;
    border-bottom: 2px solid var(--blue-100);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-body);
    font-size: .9rem;
}

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

tbody tr {
    transition: background .12s;
}
tbody tr:hover { background: var(--blue-50); }

/* ─────────────────────────────────────────
   Badge / status
───────────────────────────────────────── */
.badge {
    display: inline-block;
    background: var(--blue-50);
    color: var(--blue-700);
    border: 1px solid var(--blue-100);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.badge-market {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.badge-market.camaron {
    background: #e6f9f0;
    color: #1a6e46;
    border: 1px solid #a8dfc1;
}
.badge-market.industria {
    background: var(--blue-50);
    color: var(--blue-700);
    border: 1px solid var(--blue-100);
}

/* ─────────────────────────────────────────
   Market picker (pantalla de selección)
───────────────────────────────────────── */
.market-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 640px;
    margin: 0 auto;
}

.market-pick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 24px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    text-align: center;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    box-shadow: var(--shadow-sm);
}
.market-pick-card:hover {
    border-color: var(--blue-600);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.market-pick-card.camaron:hover {
    border-color: #1a6e46;
    box-shadow: 0 4px 16px rgba(26,110,70,.15);
}
.pick-icon   { font-size: 2.8rem; }
.pick-label  { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.pick-desc   { font-size: .82rem; color: var(--muted); line-height: 1.4; }

/* Header dentro del formulario que indica el mercado activo */
.form-market-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 1rem;
    font-weight: 700;
}
.form-market-header span:first-child { font-size: 1.4rem; }
.form-market-header > div { display: flex; align-items: center; gap: 14px; }
.form-market-header.industria {
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    color: var(--blue-700);
}
.form-market-header.camaron {
    background: #e6f5ed;
    border: 1px solid #a8dfc1;
    color: #1a6e46;
}

.btn-change-market {
    background: transparent;
    border: 1px solid currentColor;
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    opacity: .75;
    transition: opacity .15s;
}
.btn-change-market:hover { opacity: 1; }

@media (max-width: 560px) {
    .market-picker { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────
   Market tabs (legacy, kept for reference)
───────────────────────────────────────── */
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}
.market-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, background .15s, box-shadow .15s;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--muted);
}
.market-tab .market-icon { font-size: 1.6rem; }
.market-tab:hover { border-color: var(--blue-600); color: var(--blue-600); }

/* Industria/Flores activo */
.market-tab.active {
    border-color: var(--blue-600);
    border-width: 2.5px;
    background: var(--blue-50);
    color: var(--blue-700);
    box-shadow: 0 0 0 3px rgba(2, 106, 177, 0.15);
}

/* Camarón activo */
.market-tab.active.camaron {
    border-color: #1a6e46;
    border-width: 2.5px;
    background: #e6f5ed;
    color: #1a6e46;
    box-shadow: 0 0 0 3px rgba(26, 110, 70, 0.15);
}

/* Show/hide market-specific fields */
.market-section { display: none !important; }
.market-section.visible { display: block !important; }

/* ─────────────────────────────────────────
   Forms
───────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

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

.form-grid h2 {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 600;
    font-size: .88rem;
    color: var(--text);
    margin-bottom: 7px;
    letter-spacing: .01em;
}

input,
select,
textarea {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    background: #fff;
    font: inherit;
    font-size: .92rem;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input:hover, select:hover, textarea:hover {
    border-color: var(--blue-600);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(2, 106, 177, 0.15);
}

textarea { resize: vertical; }

.actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.error {
    color: var(--danger);
    font-size: .88rem;
    font-weight: 500;
    margin: 0;
}

/* ─────────────────────────────────────────
   Auth / Login
───────────────────────────────────────── */
.auth-wrapper {
    min-height: 80vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(440px, 100%);
    padding: 40px;
}

.auth-card h1 {
    font-size: 1.6rem;
    letter-spacing: -0.03em;
    color: var(--blue-600);
    margin-bottom: 4px;
}

.auth-card > p {
    margin-top: 0;
    margin-bottom: 28px;
    color: var(--muted);
    font-size: .9rem;
}

.auth-card .field {
    margin-bottom: 18px;
}

.auth-card input {
    margin-bottom: 0;
}

.auth-card .btn-submit {
    width: 100%;
    margin-top: 10px;
    padding: 13px;
    font-size: 1rem;
}

/* ─────────────────────────────────────────
   Detail view
───────────────────────────────────────── */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

dl {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 12px;
    column-gap: 20px;
}

dt {
    color: var(--muted);
    font-size: .88rem;
    font-weight: 500;
    align-self: center;
}

dd {
    margin: 0;
    text-align: right;
    font-weight: 700;
    color: var(--text);
    font-size: .92rem;
    align-self: center;
}

.total {
    font-size: 1.45rem;
    color: var(--blue-600);
    font-weight: 800;
}

/* ─────────────────────────────────────────
   Divider between dl rows
───────────────────────────────────────── */
dl dt + dd {
    border-bottom: 1px dashed var(--border);
    padding-bottom: 10px;
}
dl dt {
    border-bottom: 1px dashed var(--border);
    padding-bottom: 10px;
}
dl dt:last-of-type, dl dd:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

/* ─────────────────────────────────────────
   Responsive
───────────────────────────────────────── */
@media (max-width: 760px) {
    .topbar {
        height: auto;
        padding: 10px 4vw;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .brand { padding-right: 0; }

    .topbar nav {
        height: auto;
        gap: 2px;
        flex-wrap: wrap;
        width: 100%;
    }

    .topbar nav a {
        height: auto;
        padding: 7px 10px;
        border: none;
        border-radius: 4px;
    }
    .topbar nav a:hover,
    .topbar nav a.active {
        background: rgba(255,255,255,.08);
        border: none;
    }

    .nav-user {
        height: auto;
        padding: 6px 8px;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,.10);
        width: 100%;
        margin-left: 0;
    }

    .page-heading {
        flex-direction: column;
    }

    .metrics,
    .form-grid,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .full {
        grid-column: auto;
    }

    .auth-card {
        padding: 28px 22px;
    }
}

/* ─────────────────────────────────────────
   Spinner inline (para botones)
───────────────────────────────────────── */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin .65s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}
.btn-spinner.dark {
    border-color: rgba(2,106,177,.25);
    border-top-color: #026AB1;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Active state para links de gerencia (color amarillo) */
.topbar nav a.active[style*="f0a500"] {
    color: #f0a500 !important;
    border-bottom-color: #f0a500 !important;
    opacity: 1;
}
/* Links no activos de gerencia: un poco más opacos */
.topbar nav a[style*="f0a500"]:not(.active) {
    opacity: 0.65;
}
