/* =========================================================
   FLOWhatsapp CRM - Admin Panel Premium Dark Theme
   ========================================================= */

@font-face {
    font-family: 'Montserrat';
    src: url('fonts/Montserrat-Variable.ttf') format('truetype');
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

/* ─── CSS Variables ─── */
:root {
    --bg-primary:    #0a0f1e;
    --bg-secondary:  #0f172a;
    --bg-card:       #1e293b;
    --bg-card-hover: #243447;
    --bg-input:      #162032;
    --border:        #2d3f55;
    --border-light:  #3d5068;

    --accent:        #ddd6fe;
    --accent-hover:  #ffffff;
    --accent-action: #5b21b6;
    --accent-light:  rgba(124,58,237,0.15);
    --accent-glow:   rgba(124,58,237,0.38);
    --brand-secondary:#2563eb;
    --brand-highlight:#22d3ee;

    --text-primary:  #ffffff;
    --text-secondary:#dbe4f0;
    --text-muted:    #b8c5d8;

    --success:       #6ee7b7;
    --success-light: rgba(16,185,129,0.15);
    --warning:       #fcd34d;
    --warning-light: rgba(245,158,11,0.15);
    --danger:        #fca5a5;
    --danger-light:  rgba(239,68,68,0.15);
    --info:          #67e8f9;
    --info-light:    rgba(6,182,212,0.15);

    --sidebar-w:     260px;
    --topbar-h:      64px;
    --radius:        10px;
    --radius-sm:     6px;
    --radius-lg:     14px;
    --shadow:        0 4px 20px rgba(0,0,0,0.4);
    --transition:    0.2s cubic-bezier(0.4,0,0.2,1);
    --content-max:   1800px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    font-size: 16px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) rgba(15, 23, 42, 0.3);
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M4 2.5 22 15l-8.1 1.25L18 24l-4.2 2-4-8-5.8 5.5Z' fill='%23fff' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") 4 3, default;
}
a, button, [role="button"], label[for], select, summary { cursor: pointer; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
body {
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    background-image:
        radial-gradient(circle at 92% -10%, rgba(124,58,237,.13), transparent 30rem),
        radial-gradient(circle at -10% 100%, rgba(37,99,235,.08), transparent 32rem);
    background-attachment: fixed;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid #facc15; outline-offset: 3px; }

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.3); }
*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

/* ─── Layout ─── */
.app-wrapper { display: flex; min-height: 100vh; width: 100%; min-width: 0; }

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition);
    overflow: hidden;
}

.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: transparent;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: none;
}
.sidebar-brand .brand-icon img { width:40px;height:40px;border-radius:11px;object-fit:contain;filter:drop-shadow(0 8px 16px var(--accent-glow)); }
.sidebar-brand .brand-text { flex: 1; min-width: 0; }
.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-brand .brand-version {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #34465f transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 7px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { border: 2px solid transparent; background-clip: padding-box; }
.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 8px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all var(--transition);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}
.nav-item.active {
    background: linear-gradient(90deg, var(--accent-light) 0%, rgba(99, 102, 241, 0.02) 100%);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    font-weight: 600;
    padding-left: 9px;
}

.nav-item .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-action);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--accent-action);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}
.user-logout {
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
    background: none;
}
.user-logout:hover { color: var(--danger); }

/* ─── Main Content ─── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-w));
}

/* ─── Topbar ─── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
}
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex: 1;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb span { color: var(--text-secondary); font-weight: 500; }
.breadcrumb .sep { color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Page Content ─── */
.page-content {
    padding: clamp(18px, 2vw, 32px);
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    min-width: 0;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-header-left {}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ─── Alerts / Flash ─── */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.alert span { flex: 1; }
.alert-close {
    background: none; border: none;
    color: inherit; font-size: 1.2rem;
    cursor: pointer; opacity: 0.7;
    padding: 0 2px; line-height: 1;
}
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.alert-error   { background: var(--danger-light);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.alert-info    { background: var(--info-light);    color: var(--info);    border: 1px solid rgba(6,182,212,0.3); }

/* ─── Cards ─── */
.card {
    background: rgba(30, 41, 59, 0.45);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    min-width: 0;
}
.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 15px 35px rgba(0,0,0,0.25);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Stat Cards ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stats-grid.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: rgba(30, 41, 59, 0.45);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all var(--transition);
    cursor: default;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    min-width: 0;
}
.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: var(--accent-light);   color: var(--accent); }
.stat-icon.green  { background: var(--success-light);  color: var(--success); }
.stat-icon.red    { background: var(--danger-light);   color: var(--danger); }
.stat-icon.yellow { background: var(--warning-light);  color: var(--warning); }
.stat-icon.cyan   { background: var(--info-light);     color: var(--info); }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.stat-icon.orange { background: rgba(249,115,22,0.15); color: #f97316; }

.stat-info { flex: 1; min-width: 0; }
.stat-value {
    font-size: clamp(1.15rem, 1.5vw, 1.6rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}
.stat-trend {
    font-size: 0.72rem;
    color: var(--success);
    margin-top: 4px;
}
.stat-trend.down { color: var(--danger); }

/* Keep the six dashboard KPIs on one stable row on notebook/desktop screens. */
@media (min-width: 1200px) {
    .stats-grid.dashboard-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .dashboard-stats .stat-card { padding: 16px 14px; gap: 10px; }
    .dashboard-stats .stat-icon { width: 40px; height: 40px; }
    .dashboard-stats .stat-value { font-size: 1rem; }
    .dashboard-stats .stat-label { font-size: .71rem; line-height: 1.35; }
}

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

/* ─── Tables ─── */
.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    overscroll-behavior-inline: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: rgba(10, 15, 30, .35);
}

/* License management keeps all essential information visible without a
   horizontal scrollbar on desktop. Content wraps naturally. */
.licenses-table-wrapper {
    overflow-x: auto;
    width: 100%;
}
.licenses-table-wrapper .license-table {
    width: 100%;
    min-width: 100%;
    table-layout: auto;
}
.licenses-table-wrapper .license-table .col-select { width: 46px; text-align: center; }
.licenses-table-wrapper .license-table .col-key { width: 22%; font-size: 0.8rem; font-family: monospace; letter-spacing: 0.5px; }
.licenses-table-wrapper .license-table .col-client { width: 20%; }
.licenses-table-wrapper .license-table .col-plan { width: 9%; }
.licenses-table-wrapper .license-table .col-status { width: 9%; }
.licenses-table-wrapper .license-table .col-machines { width: 9%; }
.licenses-table-wrapper .license-table .col-expiry { width: 12%; }
.licenses-table-wrapper .license-table .col-reseller { width: 11%; }
.licenses-table-wrapper .license-table .col-price { width: 8%; }
.licenses-table-wrapper .license-table .col-actions { width: 110px; }
.licenses-table-wrapper .license-table td { overflow-wrap: anywhere; }

.license-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(15, 23, 42, .5);
}
.license-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 12px;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
}
.license-tab:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.license-tab.active { color: #fff; background: var(--accent-action); box-shadow: 0 5px 16px var(--accent-glow); }
.license-tab span { min-width: 20px; padding: 1px 6px; border-radius: 999px; text-align: center; color: inherit; background: rgba(255,255,255,.14); font-size: .72rem; }
table.data-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table thead th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
.data-table thead th:first-child { padding-left: 20px; }
.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table td {
    padding: 13px 16px;
    color: var(--text-secondary);
    vertical-align: middle;
    max-width: 320px;
}
.data-table td:first-child { padding-left: 20px; }
.data-table td strong { color: var(--text-primary); }

/* ─── Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-success   { background: var(--success-light);           color: var(--success); }
.badge-danger    { background: var(--danger-light);            color: var(--danger); }
.badge-warning   { background: var(--warning-light);           color: var(--warning); }
.badge-info      { background: var(--info-light);              color: var(--info); }
.badge-secondary { background: rgba(100,116,139,0.15);         color: var(--text-muted); }
.badge-blue      { background: var(--accent-light);            color: var(--accent); }
.badge-purple    { background: rgba(139,92,246,0.15);          color: #8b5cf6; }
.badge-orange    { background: rgba(249,115,22,0.15);          color: #f97316; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm   { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg   { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

.btn-primary   { background: var(--accent-action); color: #fff; }
.btn-primary:hover { background: #4c1d95; border-color: #c4b5fd; box-shadow: 0 0 20px var(--accent-glow); color: #fff; }

.btn-success   { background: #065f46; color: #fff; }
.btn-success:hover { background: #064e3b; color: #fff; }

.btn-danger    { background: #991b1b; color: #fff; }
.btn-danger:hover { background: #7f1d1d; color: #fff; }

.btn-warning   { background: var(--warning);  color: #000; }
.btn-warning:hover { background: #d97706; color: #000; }

.btn-secondary { background: var(--bg-card);  color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-light); color: var(--text-primary); background: var(--bg-card-hover); }

.btn-outline   { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }

/* ─── Forms ─── */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    letter-spacing: 0.02em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid #52647f;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
    appearance: none;
}
.form-control::placeholder,
.form-textarea::placeholder { color: #b8c5d8; opacity: 1; }
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
.form-select option { background: var(--bg-card); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 5px; }

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

/* ─── Input Group ─── */
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ─── Checkbox / Radio ─── */
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.form-check-label { font-size: 0.875rem; color: var(--text-secondary); cursor: pointer; }

/* ─── Search & Filters ─── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 340px;
}
.search-box .search-icon {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}
.search-box .form-control { padding-left: 36px; }

/* ─── Key display ─── */
.license-key {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--accent);
    cursor: pointer;
}
.license-key:hover { text-decoration: underline; }

/* ─── Machine pills ─── */
.machine-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.machine-count .used { color: var(--text-primary); font-weight: 600; }
.machine-count .divider { color: var(--text-muted); }

/* ─── Progress bar ─── */
.progress { background: var(--border); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width 0.4s ease; }
.progress-bar.blue   { background: var(--accent); }
.progress-bar.green  { background: var(--success); }
.progress-bar.yellow { background: var(--warning); }
.progress-bar.red    { background: var(--danger); }

/* ─── Plan chart bars ─── */
.plan-chart { display: flex; flex-direction: column; gap: 12px; }
.plan-bar-row { display: flex; align-items: center; gap: 12px; }
.plan-bar-label { font-size: 0.8rem; color: var(--text-secondary); min-width: 80px; }
.plan-bar-track { flex: 1; background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; }
.plan-bar-fill { height: 100%; border-radius: 20px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.plan-bar-count { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); min-width: 30px; text-align: right; }

/* ─── Machine cards ─── */
.machine-list { display: flex; flex-direction: column; gap: 10px; }
.machine-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.machine-icon {
    width: 36px; height: 36px;
    background: var(--accent-light);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.machine-info { flex: 1; min-width: 0; }
.machine-id { font-size: 0.8rem; font-family: monospace; color: var(--text-secondary); }
.machine-label { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.machine-date { font-size: 0.72rem; color: var(--text-muted); }

/* ─── Action buttons group ─── */
.actions-group { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }

/* ─── Divider ─── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* ─── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ─── Login Page ─── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(37,99,235,0.12) 0%, transparent 70%);
    top: -100px; left: -100px;
    pointer-events: none;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(139,92,246,0.08) 0%, transparent 70%);
    bottom: -50px; right: -50px;
    pointer-events: none;
}
.login-box {
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border: 1px solid #52647f;
    border-radius: var(--radius-lg);
    padding: 44px 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    position: relative;
    z-index: 1;
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
    width: 56px; height: 56px;
    background: var(--accent);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 16px;
    box-shadow: 0 0 30px var(--accent-glow);
}
.login-title { margin-top: 10px; font-size: 1.75rem; font-weight: 760; color: var(--text-primary); letter-spacing: -.03em; }
.login-subtitle { max-width: 340px; margin: 8px auto 0; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.55; }
.login-box .form-label { color: #ffffff; font-size: .86rem; font-weight: 750; }
.login-box .form-control { min-height: 52px; background: #162238; color: #ffffff; font-size: .94rem; }
.login-box .input-group .btn { min-width: 54px; justify-content: center; color: #ffffff; border-color: #52647f; }
.login-box .input-group { flex-wrap: nowrap; gap: 0; }
.login-box .input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.login-box .input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.login-box .btn-lg { min-height: 52px; justify-content: center; font-weight: 800; }
.login-box .text-muted { color: var(--text-secondary) !important; }
.login-box a { color: #ddd6fe !important; font-weight: 700; text-underline-offset: 4px; }
.login-box a:hover { color: #ffffff !important; }
.login-tabs {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
    gap: 4px;
}
.login-tab {
    flex: 1;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
}
.login-tab.active {
    background: var(--accent-action);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row.cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1200px) and (min-width: 769px) {
    .license-table .col-reseller,
    .license-table .col-price { display: none; }
    table.data-table.license-table { min-width: 100%; table-layout: fixed; }
    .license-table .col-select { width: 4%; }
    .license-table .col-key { width: 22%; }
    .license-table .col-client { width: 22%; }
    .license-table .col-plan { width: 10%; }
    .license-table .col-status { width: 10%; }
    .license-table .col-machines { width: 10%; }
    .license-table .col-expiry { width: 12%; }
    .license-table .col-actions { width: 10%; }
    .license-table td { overflow-wrap: anywhere; }
    .license-table .actions-group { gap: 4px; }
    .license-table .actions-group .btn {
        flex: 0 0 30px;
        width: 30px;
        height: 30px;
        padding: 0;
    }
    .data-table td, .data-table thead th { padding-inline: 8px; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 260px; }
    .sidebar {
        transform: translateX(-100%);
        width: min(86vw, 300px);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0,0,0,0.5);
    }
    .main-content { margin-left: 0; width: 100%; }
    .topbar-toggle { display: flex; }
    .page-content { padding: 16px; }
    .form-row.cols-2,
    .form-row.cols-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .topbar { padding: 0 16px; }
    .topbar-actions .text-sm { display: none; }
    .card { padding: 18px; }
    .card-header { align-items: flex-start; gap: 10px; flex-wrap: wrap; }
    .input-group { flex-wrap: wrap; gap: 8px; }
    .input-group .form-control,
    .input-group .btn { border-radius: var(--radius-sm); }

    .license-table { min-width: 0; display: block; }
    .license-table thead { display: none; }
    .license-table tbody { display: grid; gap: 12px; padding: 12px; }
    .license-table tbody tr {
        display: grid;
        position: relative;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 16px;
        padding: 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: rgba(15, 23, 42, .82);
    }
    .license-table tbody tr:hover { background: rgba(20, 31, 51, .95); }
    .license-table td,
    .license-table td:first-child {
        display: flex;
        min-width: 0;
        max-width: none;
        padding: 0;
        border: 0;
        flex-direction: column;
        align-items: flex-start;
    }
    .license-table td::before {
        content: attr(data-label);
        margin-bottom: 4px;
        color: var(--text-muted);
        font-size: .66rem;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
    }
    .license-table .col-select { position: absolute; right: 28px; }
    .license-table .col-select::before { display: none; }
    .license-table td[data-label="Chave"],
    .license-table td[data-label="Cliente"],
    .license-table td[data-label="Ações"] { grid-column: 1 / -1; }
    .license-table .license-key { overflow-wrap: anywhere; }
    .license-table .actions-group { width: 100%; }
    .license-table .actions-group .btn { flex: 1; min-height: 38px; }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 99;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 480px) {
    .login-box { padding: 28px 20px; margin: 16px; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1 1 auto; }
    .topbar-actions .btn { padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* ─── Utility Classes ─── */
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-accent   { color: var(--accent); }
.text-sm       { font-size: 0.82rem; }
.text-xs       { font-size: 0.72rem; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.mono          { font-family: 'Courier New', monospace; }
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* ─── Tooltip ─── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: var(--text-primary);
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    border: 1px solid var(--border);
    z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Loading spinner ─── */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Copy feedback ─── */
.copy-hint {
    font-size: 0.7rem;
    color: var(--success);
    display: none;
    margin-left: 4px;
    animation: fadeInOut 1.5s ease forwards;
}
@keyframes fadeInOut {
    0%   { opacity: 0; }
    20%  { opacity: 1; }
    80%  { opacity: 1; }
    100% { opacity: 0; }
}

/* ─── Danger zone ─── */
.danger-zone {
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius);
    padding: 20px;
    background: rgba(239,68,68,0.04);
}
.danger-zone-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--danger);
    margin-bottom: 8px;
}

/* ─── Quick action buttons strip ─── */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}
.quick-actions-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    align-self: center;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Detail row ─── */
.detail-row {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 140px;
    padding-top: 2px;
}
.detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    flex: 1;
    word-break: break-all;
}

/* ─── Installation registry ─── */
.installation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.installation-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.installation-card-head {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}
.installation-card-head .machine-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: var(--accent-light);
    font-size: 1.25rem;
}
.installation-code {
    margin-top: 3px;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    font-size: 0.82rem;
}
.installation-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 0;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.installation-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 16px;
}
.installation-card-actions .btn { flex: 1 1 auto; }
.machine-bind-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
    align-items: end;
}

@media (max-width: 560px) {
    .installation-card-head { grid-template-columns: 36px minmax(0, 1fr) auto; }
    .installation-card-head .machine-icon { width: 36px; height: 36px; }
    .installation-card .detail-row { flex-direction: column; gap: 3px; }
    .installation-card .detail-label { min-width: 0; }
    .machine-bind-form { grid-template-columns: minmax(0, 1fr); }
    .machine-bind-form .btn { width: 100%; }
}
