/* ============================================================
   JAuth Design Tokens & Stylesheet (Dark / Stealth Palette)
   Palette: Black surfaces, Dark Grey sidebar, Lighter Grey text, Green accent
   Style: flat, blocky, minimal radius (3px), 1px borders, no gradients
   Icons: inline SVG (stroke = currentColor), no emoji
   ============================================================ */

:root {
    --bg:            #090a0d;   /* deep black page background             */
    --surface:       #0f1216;   /* dark black cards / panels              */
    --surface-alt:   #14181f;   /* table headers, hovers, secondary cells */
    --border:        #1e242d;   /* default subtle 1px border              */
    --border-strong: #2a3340;   /* inputs, interactive borders            */

    --text:          #edf2f7;   /* primary clean light text               */
    --text-muted:    #8b96a5;   /* lighter grey secondary text/hints      */

    --sidebar:       #13171d;   /* darker grey sidebar background         */
    --sidebar-hover: #1b2129;   /* sidebar item hover                     */
    --sidebar-text:  #8e99a7;   /* sidebar inactive text                  */
    --sidebar-border:#1e242d;   /* sidebar dividing border                */

    --green:         #16a34a;   /* primary accent green                   */
    --green-dark:    #15803d;   /* button hover / border                  */
    --green-light:   #22c55e;   /* vibrant readable green for links/icons */
    --green-soft:    rgba(22, 163, 74, 0.16);   /* badge & active fill    */

    --amber:         #facc15;
    --amber-soft:    rgba(202, 138, 4, 0.15);

    --red:           #f87171;
    --red-dark:      #ef4444;
    --red-soft:      rgba(220, 38, 38, 0.16);

    --blue:          #60a5fa;
    --blue-soft:     rgba(37, 99, 235, 0.16);

    --radius:        3px;
}

* { box-sizing: border-box; }

/* Custom Dark Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #090a0d;
}
::-webkit-scrollbar-thumb {
    background: #202732;
    border-radius: var(--radius);
}
::-webkit-scrollbar-thumb:hover {
    background: #2e3848;
}

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

/* ------------------------------------------------------------
   Sidebar (Darker Grey)
   ------------------------------------------------------------ */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 224px;
    height: 100vh;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 18px 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 18px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo-img {
    width: 32px;
    height: 32px;
    flex: none;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid #232c38;
    background: #090a0d;
}

.logo-mark {
    width: 32px;
    height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    background: var(--green);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius);
}

.logo-text h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.2px;
}

.logo-text span {
    display: block;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 1px;
}

.nav {
    padding: 14px 0;
    flex: 1;
    overflow-y: auto;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0 10px 2px;
    padding: 9px 11px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.nav a svg {
    width: 16px;
    height: 16px;
    flex: none;
    opacity: .85;
}

.nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav a.active {
    background: var(--sidebar-hover);
    color: #fff;
    font-weight: 500;
}

.nav a.active svg {
    opacity: 1;
    color: var(--green-light);
}

.nav a.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--green);
}

.sidebar-footer {
    padding: 14px 18px 0;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.sidebar-footer a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-footer a svg {
    width: 15px;
    height: 15px;
}

/* ------------------------------------------------------------
   Layout & Topbar
   ------------------------------------------------------------ */
.main {
    margin-left: 224px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.crumb {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.crumb span {
    color: var(--text-muted);
    font-weight: 400;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-selector-top {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.app-selector-top select {
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #090a0d;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--text);
    cursor: pointer;
}

.user {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: background .12s ease;
}

.user:hover {
    background: var(--surface-alt);
}

.avatar {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    background: #192029;
    color: var(--text);
    font-size: 11.5px;
    font-weight: 700;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.content {
    padding: 26px;
    max-width: 1400px;
    width: 100%;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin: 0 0 4px;
    color: #ffffff;
}

.subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

/* ------------------------------------------------------------
   Panels & Cards (Black / Dark Surfaces)
   ------------------------------------------------------------ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.stat {
    padding: 17px 18px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.stat-number {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
    color: #ffffff;
}

.stat-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-meta .up {
    color: var(--green-light);
    font-weight: 600;
}

/* ------------------------------------------------------------
   Sections & Tables
   ------------------------------------------------------------ */
.section {
    margin-top: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.section-title {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: #ffffff;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.link {
    font-size: 12.5px;
    color: var(--green-light);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.link:hover {
    text-decoration: underline;
}

.section-body {
    padding: 16px 18px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 18px;
    background: #0d1014;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 13px 18px;
    border-bottom: 1px solid #161c24;
    vertical-align: middle;
    color: var(--text);
}

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

tbody tr:hover {
    background: var(--surface-alt);
}

.key {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.key:hover {
    color: var(--green-light);
}

.hwid-string {
    font-family: monospace;
    font-size: 11.5px;
    color: var(--text-muted);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    cursor: pointer;
}

.hwid-string:hover {
    color: #ffffff;
}

/* ------------------------------------------------------------
   Badges (Dark Themed with Clean Colored Strokes)
   ------------------------------------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: var(--radius);
    line-height: 1.4;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge.active   { background: var(--green-soft); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.25); }
.badge.paused   { background: var(--amber-soft); color: var(--amber); border: 1px solid rgba(250, 204, 21, 0.25); }
.badge.expired  { background: var(--red-soft);   color: var(--red); border: 1px solid rgba(248, 113, 113, 0.25); }
.badge.banned   { background: rgba(220, 38, 38, 0.22); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.35); }
.badge.unused   { background: #182029;           color: #94a3b8; border: 1px solid #2a3443; }
.badge.role     { background: var(--green-soft); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.25); }
.badge.locked   { background: var(--blue-soft);  color: var(--blue); border: 1px solid rgba(96, 165, 250, 0.25); }
.badge.unlocked { background: #161c24;           color: var(--text-muted); border: 1px solid var(--border); }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    white-space: nowrap;
}

.btn svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.btn-primary {
    background: var(--green);
    border-color: var(--green-dark);
    color: #fff;
}

.btn-primary:hover {
    background: var(--green-dark);
}

.btn-secondary {
    background: #13171d;
    border-color: #28313e;
    color: var(--text);
}

.btn-secondary:hover {
    background: #1c222b;
    border-color: #3b4859;
    color: #fff;
}

.btn-danger {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.35);
    color: var(--red);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.22);
    border-color: var(--red);
}

.btn-sm {
    padding: 5px 9px;
    font-size: 12px;
}

.btn-sm svg {
    width: 12px;
    height: 12px;
}

.btn:focus-visible,
.nav a:focus-visible,
.link:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   Form Controls & Inputs
   ------------------------------------------------------------ */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.form-group .hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 11px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: #090a0d;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}

select.form-control option {
    background: #0f1216;
    color: var(--text);
}

.form-control:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 1px var(--green);
}

textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    user-select: none;
    cursor: pointer;
    color: var(--text);
}

.form-check input[type="checkbox"] {
    accent-color: var(--green);
    width: 15px;
    height: 15px;
    margin: 0;
    cursor: pointer;
}

/* ------------------------------------------------------------
   Filter Bar & Search
   ------------------------------------------------------------ */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    min-width: 220px;
}

.search-input-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrap input {
    padding-left: 32px;
}

/* ------------------------------------------------------------
   Modals
   ------------------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 8, 0.82);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(8px);
    transition: transform .15s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
}

.modal-close:hover {
    color: #ffffff;
    background: var(--surface-alt);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #0b0d10;
}

/* ------------------------------------------------------------
   Toast Notifications
   ------------------------------------------------------------ */
.toast-container {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #14181f;
    color: #ffffff;
    border: 1px solid var(--border-strong);
    padding: 10px 16px;
    font-size: 13px;
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: slideUp .15s ease-out;
    border-left: 3px solid var(--green);
}

.toast.error {
    border-left-color: var(--red);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   Authentication View (Login / Register)
   ------------------------------------------------------------ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #07080b;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.auth-logo .logo-img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid #242c38;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 9px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.auth-tab.active {
    color: #ffffff;
    border-bottom-color: var(--green);
}

/* ------------------------------------------------------------
   Application Cards
   ------------------------------------------------------------ */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.app-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.app-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.app-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
}

.app-card-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 4px 0 16px;
    min-height: 36px;
}

.app-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.app-meta-row:last-of-type {
    border-bottom: none;
    margin-bottom: 14px;
}

.app-meta-label {
    color: var(--text-muted);
}

.app-meta-value {
    font-weight: 600;
    font-family: monospace;
    color: var(--text);
}

.app-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------
   Code Snippet Box
   ------------------------------------------------------------ */
.code-container {
    background: #08090b;
    border-radius: var(--radius);
    color: #e6edf3;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    padding: 16px;
    position: relative;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.code-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #171c24;
    border: 1px solid var(--border-strong);
    color: #c9d1d9;
    padding: 4px 9px;
    font-size: 11px;
    border-radius: var(--radius);
    cursor: pointer;
}

.code-copy-btn:hover {
    background: #232a35;
    color: #fff;
}

.tabs-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: #ffffff;
}

.tab-btn.active {
    color: var(--green-light);
    border-bottom-color: var(--green);
}

/* ------------------------------------------------------------
   Responsive Breakpoints
   ------------------------------------------------------------ */
@media (max-width: 900px) {
    .sidebar { width: 64px; }
    .logo { justify-content: center; padding: 0 0 16px; }
    .logo-text, .sidebar-footer a span { display: none; }
    .nav a { justify-content: center; padding: 11px 0; margin: 0 8px 2px; }
    .nav a span { display: none; }
    .nav a.active::before { left: -8px; }
    .main { margin-left: 64px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 16px; }
    .topbar  { padding: 0 16px; }
}

@media (max-width: 640px) {
    .stats { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stat-number { font-size: 22px; }
    th, td { padding: 10px 12px; }
    .section-head, .section-body { padding: 12px 14px; }
}
