/* =====================================================================
   YESRouter License Manager — AdminLTE2-style admin, premium indigo.
   Fixed left sidebar · top header bar · content "boxes" · small-box
   stat widgets · Inter + JetBrains Mono. Dependency-free (no Bootstrap).
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Premium indigo palette */
    --indigo-900: #1e1b4b;
    --indigo-800: #312e81;
    --indigo-700: #3730a3;
    --indigo-600: #4338ca;
    --indigo-500: #4f46e5;
    --indigo-400: #6366f1;
    --indigo-300: #818cf8;
    --indigo-50:  #eef2ff;

    --bg:      #f3f4fb;   /* app background (cool indigo-gray) */
    --panel:   #ffffff;
    --line:    #e7e8f0;
    --line-2:  #d6d8e6;

    --ink:   #1f2233;     /* headings */
    --ink-2: #41435a;     /* body */
    --ink-3: #6b6e85;     /* muted */
    --ink-4: #9aa0b5;

    --emerald: #10b981; --emerald-600:#059669;
    --amber:   #f59e0b; --amber-600:  #d97706;
    --red:     #ef4444; --red-600:    #dc2626;
    --teal:    #14b8a6;

    --sidebar-w: 238px;
    --header-h: 60px;

    --r-lg: 14px; --r-md: 10px; --r-sm: 7px;
    --shadow: 0 1px 2px rgba(31,34,51,.04), 0 4px 18px rgba(31,34,51,.06);
    --shadow-lift: 0 10px 28px rgba(67,56,202,.20);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Always reserve the vertical scrollbar so the content never shifts sideways
   when navigating between pages of different height. */
html { overflow-y: scroll; scrollbar-gutter: stable; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink-2);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
a { color: var(--indigo-500); text-decoration: none; }
a:hover { color: var(--indigo-400); }
h1,h2,h3 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.12rem; }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }
.muted, .text-mut { color: var(--ink-3); }
.subtitle { color: var(--ink-3); font-size: .92rem; margin-top: -.15rem; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }

/* ===== Top navigation bar (premium indigo) ========================== */
.topbar {
    position: sticky; top: 0; z-index: 60;
    background: linear-gradient(100deg, var(--indigo-900) 0%, var(--indigo-700) 55%, var(--indigo-600) 100%);
    box-shadow: 0 2px 14px rgba(30,27,75,.25);
}
.topbar-inner {
    display: flex; align-items: center; gap: 1.4rem;
    height: var(--header-h); padding: 0 1.6rem; max-width: 1500px; margin: 0 auto;
}
.tb-brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; flex-shrink: 0; }
.tb-brand .logo {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, var(--indigo-400), var(--indigo-300));
    color: #fff; font-weight: 800; box-shadow: 0 6px 16px rgba(129,140,248,.45);
}
.tb-brand .tb-name { font-size: .98rem; }
.tb-brand .tb-sub { color: var(--indigo-300); font-weight: 500; }
.tb-nav { display: flex; align-items: center; gap: .2rem; flex: 1; }
.tb-nav a {
    padding: .5rem .9rem; border-radius: var(--r-md); color: #c7c9ef; font-weight: 500; font-size: .93rem;
    transition: background .14s, color .14s;
}
.tb-nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.tb-nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.tb-mobile-only { display: none; }
.tb-user { display: flex; align-items: center; gap: .55rem; flex-shrink: 0; }
.tb-user .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.18); color: #fff; font-weight: 700;
    display: grid; place-items: center; font-size: .85rem;
}
.tb-user .uname { color: #fff; font-weight: 600; font-size: .9rem; }
.tb-user .logout { color: var(--indigo-300); font-size: .85rem; padding: .35rem .7rem; border-radius: var(--r-sm); }
.tb-user .logout:hover { background: rgba(255,255,255,.12); color: #fff; }
.tb-burger { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; padding: .2rem .4rem; }

/* ---- Content + footer (full width, centered container) ------------- */
.app-content { display: block; padding: 1.7rem 1.6rem 3rem; max-width: 1500px; margin: 0 auto; width: 100%; }
.app-footer {
    padding: 1.1rem 1.6rem; color: var(--ink-4); font-size: .82rem; border-top: 1px solid var(--line);
    max-width: 1500px; margin: 0 auto; width: 100%;
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.app-footer .who { color: var(--ink-3); }

/* ---- Page head ----------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .1rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ===== Boxes (AdminLTE content box) ================================= */
.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
    margin-bottom: 1.3rem;
}
.card-accent { border-top: 3px solid var(--indigo-500); }
.card-pad { padding: 1.35rem 1.5rem; }
.card-head {
    padding: .95rem 1.4rem; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    font-weight: 600; color: var(--ink);
}
.card-head h2 { margin: 0; font-size: 1.02rem; }

/* ===== Small-box stat widgets ====================================== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.05rem; margin-bottom: 1.5rem; }
.stat {
    position: relative; overflow: hidden;
    border-radius: var(--r-lg); padding: 1.15rem 1.25rem;
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    color: var(--ink);
}
.stat .stat-value { font-size: 2rem; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.stat .stat-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .8; margin-top: .25rem; }
.stat .stat-foot { font-size: .78rem; opacity: .7; margin-top: .3rem; }
.stat .stat-ico { position: absolute; right: .8rem; top: .7rem; font-size: 2.4rem; opacity: .16; }
/* coloured variants (filled, AdminLTE small-box) */
.stat.is-indigo, .stat.is-green, .stat.is-amber, .stat.is-red, .stat.is-teal { color: #fff; border: 0; }
.stat.is-indigo { background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700)); }
.stat.is-green  { background: linear-gradient(135deg, #34d399, var(--emerald-600)); }
.stat.is-amber  { background: linear-gradient(135deg, #fbbf24, var(--amber-600)); }
.stat.is-red    { background: linear-gradient(135deg, #f87171, var(--red-600)); }
.stat.is-teal   { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.stat.is-indigo .stat-ico, .stat.is-green .stat-ico, .stat.is-amber .stat-ico, .stat.is-red .stat-ico, .stat.is-teal .stat-ico { opacity: .28; }

/* ===== Tables ====================================================== */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .9rem 1.4rem; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; min-width: 180px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th {
    text-align: left; font-weight: 700; color: var(--ink-3); font-size: .73rem;
    text-transform: uppercase; letter-spacing: .04em;
    padding: .7rem .85rem; border-bottom: 2px solid var(--line); white-space: nowrap; background: #fafaff;
}
table.data td { padding: .75rem .85rem; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
/* Long identifiers (host-id, IP) wrap instead of forcing the table wider. */
table.data td.mono { word-break: break-all; max-width: 230px; }
/* Row action buttons: tidy single-line group, equal height, no wrapping. */
table.data td .actions { flex-wrap: nowrap; gap: .35rem; justify-content: flex-end; align-items: center; }
table.data td .actions .btn { white-space: nowrap; min-width: 0; }
table.data td .actions form { display: inline-flex; margin: 0; }

/* ===== DataTables — indigo theme overrides ========================= */
.dataTables_wrapper { padding: 1rem 1.4rem 1.2rem; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--line-2); border-radius: var(--r-md); padding: .45rem .7rem;
    font: inherit; color: var(--ink); outline: none; margin-left: .4rem; background: #fff;
}
.dataTables_wrapper .dataTables_filter input { min-width: 240px; }
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus { border-color: var(--indigo-400); box-shadow: 0 0 0 4px rgba(99,102,241,.14); }
.dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_length { margin-bottom: .9rem; color: var(--ink-3); font-size: .88rem; }
.dataTables_wrapper .dataTables_info { color: var(--ink-3); font-size: .85rem; padding-top: 1rem; }
.dataTables_wrapper .dataTables_paginate { padding-top: .8rem; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: .35rem .7rem !important; margin: 0 2px; border-radius: var(--r-sm) !important;
    border: 1px solid var(--line) !important; background: #fff !important; color: var(--ink-2) !important;
    cursor: pointer; font-size: .85rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--indigo-50) !important; border-color: var(--indigo-300) !important; color: var(--indigo-600) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700)) !important;
    border-color: transparent !important; color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .4; cursor: default; }
/* DataTables adds its own wrapper; drop the inner table's own margin/scroll. */
.card .dataTables_wrapper table.data { margin: 0; }
table.data thead th.sorting, table.data thead th.sorting_asc, table.data thead th.sorting_desc { cursor: pointer; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--indigo-50); }
.empty-row td { text-align: center; color: var(--ink-4); padding: 2.4rem 1rem; }

/* ===== Badges ====================================================== */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1.1;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.dot-only::before { margin: 0; }
.badge-green { background: #ecfdf5; color: var(--emerald-600); border-color: #a7f3d0; }
.badge-amber { background: #fffbeb; color: var(--amber-600); border-color: #fde68a; }
.badge-red   { background: #fef2f2; color: var(--red-600);   border-color: #fecaca; }
.badge-indigo{ background: var(--indigo-50); color: var(--indigo-600); border-color: #c7d2fe; }
.badge-gray  { background: #f3f4f6; color: var(--ink-3); border-color: #e5e7eb; }
.badge-soon  { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }

/* ===== Forms ======================================================= */
.field { display: block; margin-bottom: 1rem; }
.label-text { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .4rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; padding: .6rem .8rem; font: inherit; color: var(--ink);
    background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-md);
    transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--indigo-400); box-shadow: 0 0 0 4px rgba(99,102,241,.14); }
.inline-form { display: inline; }
.field-icon { position: relative; }
.field-icon > input { padding-left: 2.35rem; }
.field-icon > .ic { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); opacity: .65; }
.field-icon > .toggle { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); cursor: pointer; opacity: .6; background: none; border: 0; font-size: 1rem; padding: 0; }
.field-icon > .toggle:hover { opacity: 1; }

/* segmented toggle (tier vs custom) */
.seg { display: inline-flex; background: #eef0f8; border-radius: var(--r-md); padding: 3px; gap: 3px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .35rem .85rem; border-radius: var(--r-sm); font-size: .85rem; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.seg input:checked + span { background: #fff; color: var(--indigo-600); box-shadow: var(--shadow); }

/* ===== Buttons ===================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .56rem 1.05rem; font: inherit; font-weight: 600; cursor: pointer;
    border-radius: var(--r-md); border: 1px solid var(--line-2);
    background: #fff; color: var(--ink-2);
    transition: transform .1s, box-shadow .12s, background .12s, border-color .12s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--ink-4); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: .36rem .68rem; font-size: .84rem; border-radius: var(--r-sm); }
.btn-primary { background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700)); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(67,56,202,.28); }
.btn-primary:hover { box-shadow: var(--shadow-lift); }
.btn-green { background: linear-gradient(135deg, #34d399, var(--emerald-600)); color: #fff; border-color: transparent; }
.btn-amber { background: linear-gradient(135deg, #fbbf24, var(--amber-600)); color: #fff; border-color: transparent; }
.btn-block { width: 100%; }

/* ===== Alerts ====================================================== */
.alert { padding: .75rem 1rem; border-radius: var(--r-md); font-size: .9rem; margin-bottom: 1.1rem; border: 1px solid transparent; }
.alert-error   { background: #fef2f2; color: var(--red-600); border-color: #fecaca; }
.alert-success { background: #ecfdf5; color: var(--emerald-600); border-color: #a7f3d0; }
.alert-info    { background: var(--indigo-50); color: var(--indigo-600); border-color: #c7d2fe; }

/* copy-token block */
.token-box { display: flex; align-items: center; gap: .5rem; margin: 8px 0; }
.token-box code { flex: 1; padding: .55rem .7rem; background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-sm); word-break: break-all; font-family: 'JetBrains Mono', monospace; font-size: .82rem; }
.token-box.masked code { letter-spacing: .18em; }

/* ===== Login (split-screen) ======================================== */
.login-split {
    min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
    background: var(--bg);
}
/* Left brand panel — premium indigo with decorative orbs + grid */
.login-aside {
    position: relative; overflow: hidden; color: #e7e9ff;
    padding: 3rem 3.2rem; display: flex; flex-direction: column;
    background: linear-gradient(150deg, var(--indigo-900) 0%, var(--indigo-700) 55%, var(--indigo-500) 120%);
}
.login-aside::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background:
        radial-gradient(28rem 28rem at 110% -10%, rgba(129,140,248,.55), transparent 60%),
        radial-gradient(24rem 24rem at -10% 110%, rgba(45,212,191,.30), transparent 60%);
}
.login-aside::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35;
    background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 38px 38px;
    -webkit-mask-image: radial-gradient(60% 60% at 40% 30%, #000 30%, transparent 75%);
            mask-image: radial-gradient(60% 60% at 40% 30%, #000 30%, transparent 75%);
}
.login-aside > * { position: relative; z-index: 1; }
.la-brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; }
.la-brand .logo {
    width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    font-size: 1.3rem; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--indigo-400), var(--indigo-300));
    box-shadow: 0 10px 26px rgba(129,140,248,.5);
}
.la-brand .b-main { font-size: 1.05rem; line-height: 1; color: #fff; }
.la-brand .b-sub { display: block; font-size: .72rem; font-weight: 500; color: var(--indigo-300); letter-spacing: .04em; }
.la-hero { margin-top: auto; }
.la-hero h2 { color: #fff; font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .7rem; max-width: 18ch; }
.la-hero p { color: #c3c6ee; font-size: 1rem; max-width: 38ch; margin: 0; }
.la-points { margin: 1.8rem 0 0; padding: 0; list-style: none; display: grid; gap: .65rem; }
.la-points li { display: flex; align-items: center; gap: .6rem; color: #d6d8f5; font-size: .92rem; }
.la-points .tick { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: .72rem; flex-shrink: 0; }
.la-foot { margin-top: auto; padding-top: 2rem; color: #9da0d6; font-size: .8rem; }

/* Right form panel */
.login-main { display: grid; place-items: center; padding: 2rem; }
.login-card {
    width: 100%; max-width: 24rem;
    animation: card-in .5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.login-card h1 { font-size: 1.55rem; margin: 0 0 .2rem; }
.login-sub { color: var(--ink-3); margin: 0 0 1.6rem; font-size: .94rem; }
.login-card .field:last-of-type { margin-bottom: 1.25rem; }
.login-card .btn-primary { width: 100%; padding: .7rem; font-size: .98rem; }
.login-foot { text-align: center; color: var(--ink-4); font-size: .8rem; margin-top: 1.5rem; }
/* compact brand shown above the form on small screens only */
.login-mini { display: none; align-items: center; gap: .6rem; margin-bottom: 1.6rem; }
.login-mini .logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700)); }
.login-mini .t { font-weight: 700; color: var(--ink); }

.shake { animation: shake .4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(2px)} 30%,50%,70%{transform:translateX(-4px)} 40%,60%{transform:translateX(4px)} }

@media (max-width: 820px) {
    .login-split { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-mini { display: flex; }
}

/* ===== Top-nav mobile (burger -> dropdown menu) ==================== */
#navToggle { display: none; }
@media (max-width: 820px) {
    .topbar-inner { gap: .6rem; }
    .tb-brand .tb-sub { display: none; }
    .tb-burger { display: inline-block; order: 3; }
    .tb-user { order: 2; margin-left: auto; }
    .tb-user .uname, .tb-user .logout { display: none; }
    .tb-nav {
        display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: .15rem;
        background: var(--indigo-800); padding: .5rem .6rem;
        box-shadow: 0 14px 26px rgba(30,27,75,.35);
    }
    #navToggle:checked ~ .topbar .tb-nav { display: flex; }
    .tb-mobile-only { display: block; border-top: 1px solid rgba(255,255,255,.1); margin-top: .25rem; padding-top: .25rem; }
    .app-content { padding: 1.2rem 1rem 3rem; }
    .page-head { flex-direction: column; align-items: stretch; }
}
