/* ==========================================================================
   EdgeRouter Manager · estilo "NOC / patch panel"
   Paleta petróleo + cian de señal + ámbar. Tipografía monoespaciada como
   firma (estos equipos viven en la línea de comandos).
   ========================================================================== */

:root {
    --bg:        #0c1a20;
    --bg-grad:   #0a161b;
    --panel:     #112730;
    --panel-2:   #15303a;
    --line:      #21424e;
    --line-soft: #1a3540;
    --ink:       #e7f2f3;
    --ink-dim:   #aac6cc;
    --muted:     #6f969e;
    --accent:    #34d6c2;   /* cian de enlace */
    --accent-dk: #1d8f81;
    --warm:      #f0a44b;   /* ámbar: trabajando / aviso */
    --ok:        #57d27f;   /* enlace activo */
    --danger:    #ef6f6f;
    --offline:   #557079;

    --mono: "JetBrains Mono", ui-monospace, "DejaVu Sans Mono", "SFMono-Regular",
            Menlo, Consolas, monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(52, 214, 194, .07), transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-grad) 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Tipografía -------------------------------------------------------- */
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--accent);
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--ink-dim); }

/* ======================================================================
   Shell de aplicación
   ====================================================================== */
.app {
    display: grid;
    grid-template-columns: 268px 1fr;
    min-height: 100vh;
}

/* --- Barra lateral (panel de parcheo de equipos) ---------------------- */
.sidebar {
    background: linear-gradient(180deg, #0e2128, #0b1a20);
    border-right: 1px solid var(--line);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.brand {
    display: flex; align-items: center; gap: 11px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.brand .logo {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dk));
    display: grid; place-items: center;
    box-shadow: 0 0 18px rgba(52, 214, 194, .35);
    flex: none;
}
.brand .logo svg { width: 20px; height: 20px; }
.brand .name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand .sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: var(--radius-sm);
    color: var(--ink-dim); font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--panel); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--panel-2); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
.nav a svg { width: 17px; height: 17px; opacity: .85; flex: none; }

.rack {
    margin-top: auto;
    border-top: 1px solid var(--line-soft);
    padding-top: 14px;
}
.rack-title {
    display: flex; justify-content: space-between; align-items: baseline;
    font-family: var(--mono); font-size: 10px; letter-spacing: .16em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 9px;
}
.port {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 9px; border-radius: var(--radius-sm);
    border: 1px solid transparent;
}
.port:hover { background: var(--panel); border-color: var(--line-soft); text-decoration: none; }
.port .led { flex: none; }
.port .port-name { font-size: 13px; color: var(--ink); font-weight: 550; }
.port .port-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.port .port-body { min-width: 0; }
.port .port-name, .port .port-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* LED de enlace — la firma del panel */
.led {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--offline);
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
    position: relative;
}
.led.online { background: var(--ok); box-shadow: 0 0 8px rgba(87, 210, 127, .9); animation: pulse 2.2s infinite; }
.led.offline { background: var(--danger); box-shadow: 0 0 6px rgba(239, 111, 111, .6); }
.led.unknown { background: var(--offline); }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(87, 210, 127, .9); }
    50%      { box-shadow: 0 0 14px rgba(87, 210, 127, .35); }
}

/* --- Área principal --------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 28px; border-bottom: 1px solid var(--line-soft);
    gap: 16px;
}
.topbar .title h1 { font-size: 20px; }
.topbar .title p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.userchip {
    display: flex; align-items: center; gap: 9px;
    font-size: 13px; color: var(--ink-dim);
}
.userchip .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--panel-2); border: 1px solid var(--line);
    display: grid; place-items: center; font-family: var(--mono);
    font-size: 12px; color: var(--accent);
}
.content { padding: 28px; flex: 1; }

/* ======================================================================
   Componentes
   ====================================================================== */
.card {
    background: linear-gradient(180deg, var(--panel), #0f242c);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }

.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--panel); border: 1px solid var(--line-soft);
    border-radius: var(--radius); padding: 15px 17px;
}
.stat .k { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 28px; font-weight: 680; margin-top: 4px; font-family: var(--mono); }
.stat .v.accent { color: var(--accent); }
.stat .v.ok { color: var(--ok); }
.stat .v.danger { color: var(--danger); }

/* Tarjeta de dispositivo */
.device {
    display: flex; flex-direction: column; gap: 14px;
    padding: 18px; border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--panel), #0f242c);
    transition: border-color .15s ease, transform .15s ease;
}
.device:hover { border-color: var(--accent-dk); transform: translateY(-2px); }
.device .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.device .dname { font-size: 16px; font-weight: 650; }
.device .dhost { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 2px; }
.device .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.device .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 12.5px; }
.device .meta .lbl { color: var(--muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.device .actions { display: flex; gap: 8px; margin-top: 2px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--mono); font-size: 11px; padding: 3px 9px;
    border-radius: 20px; border: 1px solid var(--line);
    color: var(--ink-dim); background: rgba(255,255,255,.02);
}
.badge.ok { color: var(--ok); border-color: rgba(87,210,127,.4); }
.badge.danger { color: var(--danger); border-color: rgba(239,111,111,.4); }
.badge.warm { color: var(--warm); border-color: rgba(240,164,75,.4); }
.badge.accent { color: var(--accent); border-color: rgba(52,214,194,.4); }

/* --- Botones ---------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--sans); font-size: 13.5px; font-weight: 600;
    padding: 9px 15px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
    cursor: pointer; transition: background .15s, border-color .15s, opacity .15s;
    text-decoration: none;
}
.btn:hover { border-color: var(--accent-dk); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-dk)); border: none; color: #04241f; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(239,111,111,.35); background: transparent; }
.btn-danger:hover { background: rgba(239,111,111,.1); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Formularios ------------------------------------------------------ */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 6px; font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
    width: 100%; padding: 10px 12px;
    background: #0b1c23; border: 1px solid var(--line);
    border-radius: var(--radius-sm); color: var(--ink);
    font-family: var(--sans); font-size: 14px;
}
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52, 214, 194, .15);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* --- Consola / terminal (firma) --------------------------------------- */
.console-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.cmd-palette { display: flex; flex-direction: column; gap: 14px; }
.cmd-group .cmd-cat {
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em;
    text-transform: uppercase; color: var(--muted); margin: 0 0 7px;
}
.cmd-btn {
    display: block; width: 100%; text-align: left;
    padding: 8px 11px; margin-bottom: 5px; font-size: 12.5px;
    background: var(--panel); border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm); color: var(--ink-dim); cursor: pointer;
}
.cmd-btn:hover { border-color: var(--accent-dk); color: var(--ink); }
.cmd-btn .cmd-code { font-family: var(--mono); font-size: 11px; color: var(--accent); display: block; margin-top: 2px; }

.terminal {
    background: #06121700; border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
    min-height: 60vh;
}
.term-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 15px; background: #0c2129; border-bottom: 1px solid var(--line);
}
.term-head .dots { display: flex; gap: 6px; }
.term-head .dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.term-head .dots .r { background: #e0625e; } .term-head .dots .y { background: #e0b14e; } .term-head .dots .g { background: #5bbd6a; }
.term-head .sel { display: flex; align-items: center; gap: 8px; }
.term-head select { width: auto; padding: 6px 10px; font-family: var(--mono); font-size: 12.5px; }
.term-body {
    flex: 1; padding: 16px 18px; overflow-y: auto; max-height: 56vh;
    font-family: var(--mono); font-size: 13px; line-height: 1.55;
    background: linear-gradient(180deg, #06151b, #050f13);
    white-space: pre-wrap; word-break: break-word;
}
.term-line .prompt { color: var(--accent); }
.term-line .prompt .at { color: var(--ink-dim); }
.term-line.in { color: var(--ink); }
.term-line.out { color: var(--ink-dim); }
.term-line.err { color: var(--danger); }
.term-line.info { color: var(--warm); }
.term-input {
    display: flex; align-items: center; gap: 9px;
    padding: 11px 15px; border-top: 1px solid var(--line); background: #0a1a20;
}
.term-input .ps1 { font-family: var(--mono); font-size: 13px; color: var(--accent); white-space: nowrap; }
.term-input input {
    flex: 1; background: transparent; border: none; padding: 4px 0;
    font-family: var(--mono); font-size: 13px; color: var(--ink);
}
.term-input input:focus { outline: none; box-shadow: none; }
.spinner {
    width: 14px; height: 14px; border: 2px solid var(--line);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Tablas ----------------------------------------------------------- */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
table.t th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
table.t td.mono { font-family: var(--mono); font-size: 12px; }
table.t tr:hover td { background: rgba(255,255,255,.015); }

/* --- Alertas ---------------------------------------------------------- */
.alert { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.alert.err { background: rgba(239,111,111,.08); border-color: rgba(239,111,111,.4); color: #ffb9b9; }
.alert.ok { background: rgba(87,210,127,.08); border-color: rgba(87,210,127,.4); color: #b6f0c8; }
.alert.warn { background: rgba(240,164,75,.08); border-color: rgba(240,164,75,.4); color: #ffd9a8; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.mt { margin-top: 22px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .5; margin-bottom: 12px; }

/* ======================================================================
   Login
   ====================================================================== */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 390px; }
.login-card .brand { justify-content: center; border: none; padding-bottom: 22px; }
.login-card .card-pad { padding: 26px 26px 30px; }

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .rack { display: none; }
    .nav { flex-direction: row; flex-wrap: wrap; margin-left: auto; }
    .console-wrap { grid-template-columns: 1fr; }
    .cmd-palette { flex-direction: row; flex-wrap: wrap; }
    .cmd-group { flex: 1 1 200px; }
}
@media (max-width: 560px) {
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    .row2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, .led.online { animation: none !important; transition: none !important; }
}

/* ============ Red · mapeos DHCP y colas QoS ============================= */
.net-toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding-bottom: 14px; margin-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
}
.net-toolbar .led { flex: none; }
.net-select {
    flex: 1 1 240px; min-width: 0;
    background: var(--bg); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 9px 11px; font-family: var(--mono); font-size: 12.5px;
}
.net-select:focus { outline: none; border-color: var(--accent); }
.net-status { font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 18px; }
.net-status .spinner { vertical-align: -2px; margin-right: 6px; }
.net-err { color: var(--danger); }

.qsection { margin-top: 22px; }
.qsection:first-child { margin-top: 8px; }
.qsection > h2 {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
    color: var(--ink-dim); font-family: var(--mono); font-weight: 600;
    margin: 0 0 10px; padding-bottom: 7px;
    border-bottom: 1px dashed var(--line-soft);
}
.qsection .count {
    font-size: 11px; color: var(--bg); background: var(--accent);
    border-radius: 999px; padding: 1px 8px; font-weight: 700; letter-spacing: 0;
}
.qmeta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.qcard {
    border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
    background: var(--panel-2); margin-bottom: 8px; overflow: hidden;
}
.qhead {
    display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
    padding: 10px 12px; cursor: pointer; user-select: none;
}
.qhead:hover { background: rgba(255,255,255,.02); }
.qhead::before {
    content: "▸"; color: var(--accent); font-size: 11px;
    transition: transform .15s ease; flex: none;
}
.qcard.open .qhead::before { transform: rotate(90deg); }
.qname { font-family: var(--mono); font-size: 13px; color: var(--ink); font-weight: 600; }
.qtag {
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em;
    color: var(--accent); background: rgba(52,214,194,.10);
    border: 1px solid var(--accent-dk); border-radius: 4px; padding: 1px 7px;
}
.qtag.dir { color: var(--warm); background: rgba(240,164,75,.10); border-color: rgba(240,164,75,.4); }
.qdetails {
    display: none; white-space: pre-wrap; word-break: break-word;
    font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim);
    padding: 0 12px 12px 30px; line-height: 1.65;
}
.qcard.open .qdetails { display: block; }

/* ---- Red · controles de edición -------------------------------------- */
.editlock { margin-bottom: 14px; padding: 8px 11px; border: 1px dashed var(--line);
            border-radius: var(--radius-sm); background: rgba(240,164,75,.06); color: var(--warm); }
.btn-xs { padding: 3px 9px; font-size: 11.5px; border-radius: 5px; }
.btn-xs.danger, .btn-ghost.danger { color: var(--danger); border-color: rgba(239,111,111,.35); }
.btn-ghost.danger:hover { background: rgba(239,111,111,.10); }

.rowacts { white-space: nowrap; text-align: right; }
.rowacts .btn { margin-left: 5px; }

input.mini, select.mini {
    width: auto; min-width: 90px; padding: 6px 9px;
    font-family: var(--mono); font-size: 12px;
    background: #0b1c23; border: 1px solid var(--line);
    border-radius: 5px; color: var(--ink);
}
input.mini:focus, select.mini:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(52,214,194,.15);
}

.editbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-top: 12px; padding: 11px 12px;
    background: var(--panel-2); border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
}
.editbar input.mini { flex: 1 1 130px; }

.qbody { padding: 6px 12px 12px; }
.qrow {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 7px 0; border-bottom: 1px dashed var(--line-soft);
}
.qrow:last-child { border-bottom: none; }
.qrk { font-family: var(--mono); font-size: 12px; color: var(--accent); min-width: 130px; }
.qrv { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.qrl { font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.qrl input.mini { min-width: 110px; }
.qfoot { margin-top: 10px; }

/* colas avanzadas: inputs compactos dentro de la tabla */
.aqrow input.mini { min-width: 76px; width: 92px; }
.t td .mini { padding: 5px 7px; }

/* consumo: resaltar clientes con tráfico ahora */
.t tr.hot td { background: rgba(52,214,194,.07); }
.t tr.hot td:nth-child(3), .t tr.hot td:nth-child(4) { color: var(--accent); }

/* salida cruda de diagnóstico */
.rawout {
    white-space: pre; overflow-x: auto; max-height: 320px;
    font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
    background: #0b1c23; border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm); padding: 10px 12px; margin: 0;
}
