/* mikrotik-firewall — estilo derivado de web-estilo.md */

/* ============ 1. TOKENS ============ */
:root {
    --canvas:   hsl(220, 20%, 97%);
    --panel:    hsl(0, 0%, 100%);
    --elevated: hsl(220, 14%, 96%);
    --inset:    hsl(220, 16%, 94%);

    --ink:       hsl(220, 25%, 12%);
    --secondary: hsl(220, 12%, 40%);
    --muted:     hsl(220, 10%, 55%);
    --faint:     hsl(220, 8%, 70%);

    --border:        rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-strong: rgba(0, 0, 0, 0.14);

    --signal:        hsl(165, 70%, 36%);
    --signal-hover:  hsl(165, 70%, 32%);
    --signal-soft:   hsl(165, 50%, 94%);
    --signal-text:   hsl(165, 65%, 28%);
    --signal-border: hsla(165, 70%, 36%, 0.2);

    --purple-soft:   hsl(270, 40%, 95%);
    --purple-text:   hsl(270, 45%, 50%);
    --purple-border: hsla(270, 50%, 55%, 0.2);
    --red-soft:      hsl(0, 70%, 96%);
    --red-text:      hsl(0, 70%, 42%);
    --red-border:    hsla(0, 70%, 42%, 0.2);
    --amber-soft:    hsl(35, 90%, 94%);
    --amber-text:    hsl(28, 75%, 38%);
    --amber-border:  hsla(28, 75%, 38%, 0.22);
    --grey-soft:     hsl(220, 12%, 94%);
    --grey-text:     hsl(220, 12%, 40%);
    --grey-border:   rgba(0, 0, 0, 0.1);

    /* spacing escalado +25% respecto a la base original */
    --sp-1: 5px;  --sp-2: 10px; --sp-3: 15px; --sp-4: 20px;
    --sp-5: 25px; --sp-6: 30px; --sp-8: 40px; --sp-10: 50px;
    --sp-12: 60px; --sp-16: 80px;

    --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px;

    --font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ============ 2. BASE ============ */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font);
    font-size: 17.5px;   /* base 14px * 1.25 — todo lo rem escala con esto */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--signal-text); text-decoration: none; transition: color 140ms ease; }
a:hover { color: var(--signal); }

code, pre, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.trace-line {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--signal) 20%, var(--signal) 80%, transparent);
    opacity: 0.6;
}

.shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--sp-6);
}

/* ============ 3. TOPNAV ============ */
.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-5);
    padding: var(--sp-3) var(--sp-4);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    margin-bottom: var(--sp-6);
}

.brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand .brand-logo {
    height: 28px;
    width: auto;
    display: block;
}
.brand .sub {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav-links { display: flex; gap: var(--sp-1); }
.nav-links a {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 140ms ease, color 140ms ease;
}
.nav-links a:hover { color: var(--ink); background: var(--elevated); }
.nav-links a.active {
    background: var(--signal-soft);
    color: var(--signal-text);
}
.nav-links a.nav-danger {
    color: var(--red-text);
    font-weight: 600;
    letter-spacing: 0.02em;
}
.nav-links a.nav-danger:hover {
    background: var(--red-soft);
    color: var(--red-text);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
}
.user-chip a { color: var(--muted); }
.user-chip a:hover { color: var(--red-text); }

/* ============ 4. PAGE HEAD ============ */
.page-head { margin-bottom: var(--sp-6); }
.page-head h1 {
    margin: 0 0 var(--sp-1) 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.page-head .sub {
    margin: 0;
    color: var(--muted);
    font-size: 0.8125rem;
}
.page-head .sub code { color: var(--ink); background: var(--inset); padding: 1px 6px; border-radius: 3px; font-size: 0.8em; }

/* ============ 5. METRICS ============ */
.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.metric {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4) var(--sp-5);
    position: relative;
    overflow: hidden;
    animation: fade-up 380ms ease-out both;
}
.metric:nth-child(1) { animation-delay: 0ms; }
.metric:nth-child(2) { animation-delay: 50ms; }
.metric:nth-child(3) { animation-delay: 100ms; }
.metric:nth-child(4) { animation-delay: 150ms; }
.metric::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--signal-border), transparent);
}
.metric-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: var(--sp-2);
}
.metric-value {
    font-family: var(--mono);
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.metric-foot {
    margin-top: var(--sp-1);
    font-size: 0.7rem;
    color: var(--muted);
}

/* ============ 6. CARDS / GRID ============ */
.grid { display: grid; gap: var(--sp-4); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    animation: fade-up 380ms ease-out 180ms both;
}
.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
.card-head h2 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink);
}
.card-head .hint {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.card-body { padding: var(--sp-4); }
.card-body.flat { padding: 0; }

/* ============ 7. FILTERS / FORMS ============ */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--sp-3);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
}
.filter-group { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 160px; }
.filter-group.grow { flex: 1; min-width: 220px; }
.filter-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.filter-input, .filter-select, .filter-textarea {
    font-family: var(--mono);
    font-size: 0.8125rem;
    padding: var(--sp-2) var(--sp-3);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--ink);
    transition: border 140ms ease, box-shadow 140ms ease;
}
.filter-input:focus, .filter-select:focus, .filter-textarea:focus {
    outline: none;
    border-color: var(--signal);
    box-shadow: 0 0 0 3px hsla(165, 70%, 36%, 0.12);
}
.filter-textarea { min-height: 140px; resize: vertical; line-height: 1.4; }

.filter-actions { display: flex; gap: var(--sp-2); }

/* ============ 8. BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-4);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--secondary);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border 140ms ease;
    text-decoration: none;
}
.btn:hover { color: var(--ink); background: var(--elevated); }
.btn-primary {
    background: var(--signal);
    border-color: var(--signal);
    color: #fff;
}
.btn-primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); color: #fff; }
.btn-ink {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}
.btn-ink:hover { background: hsl(220, 25%, 18%); color: #fff; }
.btn-danger {
    background: var(--panel);
    border-color: var(--red-border);
    color: var(--red-text);
}
.btn-danger:hover { background: var(--red-soft); color: var(--red-text); }
.btn-danger-solid {
    background: var(--red-text);
    border-color: var(--red-text);
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.btn-danger-solid:hover   { background: hsl(0, 72%, 36%); border-color: hsl(0, 72%, 36%); color: #fff; }
.btn-danger-solid:disabled { background: var(--faint); border-color: var(--faint); color: var(--panel); cursor: not-allowed; }
.btn.off { pointer-events: none; opacity: 0.3; }

/* ============ 9. TABLES ============ */
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: auto;
    animation: fade-up 380ms ease-out 180ms both;
}
table { width: 100%; border-collapse: collapse; }
thead th {
    position: sticky;
    top: 0;
    background: var(--panel);
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: var(--sp-3) var(--sp-4);
    font-size: 0.8125rem;
    color: var(--secondary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--elevated); }
tbody tr.row-pending td:first-child { box-shadow: inset 3px 0 0 var(--amber-text); }
tbody tr.row-pending td { background: hsla(35, 90%, 94%, 0.35); }
tbody tr.row-pending:hover td { background: var(--amber-soft); }

.col-num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.col-ip  { font-family: var(--mono); white-space: nowrap; }
.col-ip a { color: var(--ink); border-bottom: 1px dotted var(--faint); }
.col-ip a:hover { color: var(--signal); border-bottom-color: var(--signal); }
.col-date { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.col-rule { font-family: var(--mono); font-size: 0.75rem; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-check { width: 32px; text-align: center; }
.empty { padding: var(--sp-10); text-align: center; color: var(--muted); font-size: 0.8125rem; }

/* ============ 10. TAGS ============ */
.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--signal-soft);
    color: var(--signal-text);
    border: 1px solid var(--signal-border);
    white-space: nowrap;
}
.tag.tag-red    { background: var(--red-soft);    color: var(--red-text);    border-color: var(--red-border); }
.tag.tag-amber  { background: var(--amber-soft);  color: var(--amber-text);  border-color: var(--amber-border); }
.tag.tag-purple { background: var(--purple-soft); color: var(--purple-text); border-color: var(--purple-border); }
.tag.tag-grey   { background: var(--grey-soft);   color: var(--grey-text);   border-color: var(--grey-border); }

/* ============ 11. NOTICES ============ */
.notice {
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--signal);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    font-size: 0.8125rem;
    color: var(--secondary);
}
.notice.error { border-left-color: var(--red-text); }
.notice.warning { border-left-color: var(--amber-text); }
.notice.success { border-left-color: var(--signal); }

/* ============ 12. LOGIN ============ */
.login-wrap {
    min-height: calc(100vh - var(--sp-12));
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    position: relative;
    overflow: hidden;
    animation: fade-up 380ms ease-out both;
}
.login-card::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--signal) 50%, transparent);
    opacity: 0.7;
}
.login-card .login-logo {
    display: block;
    height: 32px;
    width: auto;
    margin: 0 auto var(--sp-4) auto;
}
.login-card h1 {
    margin: 0 0 var(--sp-1) 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-align: center;
}
.login-card .sub {
    text-align: center;
}
.login-card .sub {
    margin: 0 0 var(--sp-5) 0;
    color: var(--muted);
    font-size: 0.8125rem;
}
.login-card form { display: flex; flex-direction: column; gap: var(--sp-3); }
.login-card .btn-ink { margin-top: var(--sp-2); justify-content: center; }

/* ============ 13. PAGING ============ */
.paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    padding: var(--sp-4) 0;
    font-size: 0.8125rem;
}
.page-info { font-family: var(--mono); color: var(--muted); }

/* ============ 14. CHECKBOXES ============ */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--signal);
    cursor: pointer;
}

/* ============ 15. PREFIX LIST (ASN flow) ============ */
.prefix-list {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    max-height: 520px;
    overflow: auto;
}
.prefix-row {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
.prefix-row:last-child { border-bottom: none; }
.prefix-row:hover { background: var(--elevated); }
.prefix-row .cidr { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink); }
.prefix-row .meta { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.prefix-row.disabled-row { opacity: 0.55; cursor: not-allowed; background: var(--inset); }
.prefix-row.disabled-row:hover { background: var(--inset); }
.prefix-row.disabled-row .cidr { text-decoration: line-through; color: var(--muted); }
.prefix-row[hidden] { display: none; }

/* ============ MODAL (confirmación destructiva) ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: hsla(220, 25%, 15%, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--sp-4);
    animation: fade-in 140ms ease-out;
}
.modal-backdrop.active { display: flex; }
.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    max-width: 480px;
    width: 100%;
    padding: var(--sp-5) var(--sp-6) var(--sp-6);
    animation: fade-up 280ms ease-out;
}
.modal h2 {
    margin: 0 0 var(--sp-3) 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--red-text);
}
.modal p {
    margin: 0 0 var(--sp-3) 0;
    color: var(--secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}
.modal .modal-actions {
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
    margin-top: var(--sp-5);
}

/* ============ 16. LOADING OVERLAY ============ */
.overlay {
    position: fixed;
    inset: 0;
    background: hsla(220, 20%, 90%, 0.65);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fade-in 140ms ease-out;
}
.overlay.active { display: flex; }
.overlay-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4) var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    font-size: 0.8125rem;
    color: var(--secondary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--signal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ============ 17. ANIMATIONS ============ */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ 17. SCROLLBAR (webkit) ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============ 18. RESPONSIVE ============ */
@media (max-width: 1024px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .metrics { grid-template-columns: 1fr; }
    .shell { padding: var(--sp-4); }
    .metric-value { font-size: 1.5rem; }
    thead th, tbody td { padding: var(--sp-2) var(--sp-3); }
    .hide-mobile { display: none; }
    .topnav { flex-wrap: wrap; }
    .nav-links { order: 3; width: 100%; }
}
