.tab-content.active {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 118px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -26px;
    top: -26px;
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: rgba(20, 184, 166, 0.09);
}

.stat-num {
    position: relative;
    z-index: 1;
    color: var(--text);
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.stat-label {
    position: relative;
    z-index: 1;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
}

.card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
}

.card h3 {
    margin-bottom: 18px;
    color: var(--text);
    font-size: 17px;
    font-weight: 850;
}

.platform-chart {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.platform-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fbff, #effdfa);
}

.platform-item .platform-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.platform-item .platform-count {
    min-width: 34px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    text-align: center;
    font-weight: 900;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-soft);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.toolbar select,
.toolbar input,
.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: border 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.toolbar select,
.toolbar input {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
}

.toolbar input {
    width: 220px;
}

.toolbar select:focus,
.toolbar input:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}

.btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    transition: transform 0.16s ease, background 0.16s ease, border 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
    background: #f8fafc;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.btn-primary {
    border-color: var(--primary);
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(20, 184, 166, 0.22);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
}

.btn-danger {
    border-color: #fecaca;
    color: var(--danger);
}

.btn-danger:hover {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
}

.btn-sm {
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.btn-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 66vh;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f8fafc;
    color: #475569;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

.table-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}

.table-sort-btn.active {
    color: var(--primary-hover);
}

.table-sort-btn:hover {
    color: var(--primary-hover);
}

td {
    border-bottom: 1px solid #edf2f7;
    color: #26364d;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f8fffd;
}

table {
    min-width: max-content;
}

th:last-child,
td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: #ffffff;
    box-shadow: -4px 0 8px rgba(15, 23, 42, 0.06);
}

th:last-child {
    background: #f8fafc;
    z-index: 4;
}

tr:hover td:last-child {
    background: #f8fffd;
}

body.dark-mode th:last-child {
    background: #172033;
}

body.dark-mode td:last-child {
    background: #111827;
}

body.dark-mode tr:hover td:last-child {
    background: #1e293b;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.badge-idle {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-active {
    background: #dcfce7;
    color: #15803d;
}

.badge-maintenance {
    background: #fef3c7;
    color: #b45309;
}

.badge-retired {
    background: #f1f5f9;
    color: #64748b;
}

.badge-normal {
    background: #dcfce7;
    color: #15803d;
}

.badge-frozen {
    background: #fef3c7;
    color: #b45309;
}

.badge-banned {
    background: #fee2e2;
    color: #dc2626;
}

.actions {
    display: flex;
    gap: 6px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 600;
}

.pagination-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pagination-btns {
    display: flex;
    align-items: center;
    gap: 3px;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.page-arrow,
.page-num {
    min-width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background 0.14s, color 0.14s, border 0.14s;
}

.page-arrow svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.page-arrow:hover,
.page-num:hover {
    background: #f0fdfa;
    border-color: #5eead4;
    color: var(--primary);
}

.page-num.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(13,148,136,0.3);
}

.page-arrow[disabled],
.page-num[disabled] {
    cursor: not-allowed;
    opacity: 0.35;
    pointer-events: none;
}

.page-dots {
    min-width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 1px;
}

body.dark-mode .page-arrow,
body.dark-mode .page-num {
    background: var(--card-bg);
    border-color: var(--border);
}
body.dark-mode .page-arrow:hover,
body.dark-mode .page-num:hover {
    background: #1e293b;
    border-color: #5eead4;
    color: #5eead4;
}
body.dark-mode .page-num.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-size-select {
    margin-left: 4px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}
body.dark-mode .page-size-select {
    background: var(--card-bg);
    border-color: var(--border);
    color: #cbd5e1;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding: 56px 20px;
    background: rgba(15, 23, 42, 0.46);
    backdrop-filter: blur(8px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: 520px;
    max-width: 100%;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
    animation: slideDown 0.2s ease;
}

.modal-device {
    width: 720px;
}

.modal-lg {
    width: 760px;
}

@keyframes slideDown {
    from {
        transform: translateY(-18px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: #f8fbff;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: #eef2f7;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
}

.modal-footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: #fbfdff;
}

.app-dialog-overlay {
    align-items: center;
    padding: 20px;
}

.app-dialog {
    width: 380px;
    max-width: 100%;
    padding: 28px;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
    text-align: center;
}

.app-dialog-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin: 0 auto 14px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 900;
}

.app-dialog h3 {
    margin-bottom: 8px;
    font-size: 20px;
}

.app-dialog p {
    color: var(--text-secondary);
    font-size: 14px;
}

.app-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 850;
}

.form-group .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.device-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}

.device-form-grid .form-group {
    margin-bottom: 0;
}

.field-full {
    grid-column: 1 / -1;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    margin-bottom: 12px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
    color: #475569;
    font-size: 14px;
    font-weight: 900;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px 20px;
}

.detail-item {
    display: flex;
    padding: 5px 0;
    font-size: 13px;
}

.detail-item .detail-label {
    min-width: 76px;
    color: var(--text-secondary);
}

.detail-item .detail-value {
    color: var(--text);
    font-weight: 750;
}

.detail-sub-table {
    width: 100%;
    margin-top: 8px;
}

.detail-sub-table th {
    background: #f5f8fc;
}

.empty-text {
    padding: 24px;
    color: var(--text-secondary);
    text-align: center;
