* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    font-size: clamp(1rem, 2vw, 1.125rem);
}

.header {
    background: #1a1a2e;
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__logo {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

.header__nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    color: #aaa;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.header__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #aaa;
}

.main {
    flex: 1;
    padding: 24px;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.footer {
    background: #1a1a2e;
    color: #666;
    text-align: center;
    padding: 12px;
    font-size: 12px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.15s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #4a6cf7;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
}

.btn--primary {
    background: #4a6cf7;
    color: #fff;
}

.btn--primary:hover {
    background: #3a5ce5;
}

.btn--danger {
    background: #e74c3c;
    color: #fff;
}

.btn--danger:hover {
    background: #c0392b;
}

.btn--sm {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 44px;
}

.btn--ghost {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
}

.btn--ghost:hover {
    background: #f0f0f0;
}

.btn--secondary {
    background: #6c757d;
    color: #fff;
    border: 1px solid #6c757d;
}

.btn--secondary:hover {
    background: #5a6268;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.card__desc {
    font-size: 13px;
    color: #888;
    margin-bottom: 16px;
}

/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.auth-card h1 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    margin-bottom: 4px;
}

.auth-card .subtitle {
    color: #888;
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-card .link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #888;
}

.auth-card .link a {
    color: #4a6cf7;
    text-decoration: none;
}

/* Alert */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert--error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.alert--success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert--info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    font-weight: 600;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
}

/* Key display */
.key-display {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
    margin-bottom: 12px;
}

/* Empty state */
.empty {
    text-align: center;
    padding: 40px;
    color: #aaa;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.page-header .desc {
    font-size: 14px;
    color: #888;
    margin-top: 4px;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding: 12px 0;
    border-top: 1px solid #eee;
}

.pagination__sizes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination__label {
    font-size: 13px;
    color: #666;
    margin-right: 4px;
}

.pagination__size {
    padding: 4px 10px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.pagination__size:hover { background: #f0f0f0; }

.pagination__size--active {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.pagination__nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination__btn {
    padding: 4px 10px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.pagination__btn:hover { background: #f0f0f0; }

.pagination__btn--active {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.pagination__dots {
    padding: 0 4px;
    color: #888;
}

.pagination__info {
    font-size: 13px;
    color: #888;
    width: 100%;
    text-align: center;
}

/* Search */
.search-box {
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #1a1a2e;
}

/* === TABLE WRAP (responsive scroll) === */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stats-grid--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

/* === HAMBURGER TOGGLE === */
.header__toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

/* ============================================
   RESPONSIVE — TABLET (640–1024px)
   ============================================ */
@media (max-width: 1024px) {
    .header {
        padding: 0 16px;
        gap: 16px;
    }

    .header__nav {
        gap: 2px;
    }

    .nav-link {
        font-size: 13px;
        padding: 6px 8px;
    }

    .main {
        padding: 20px;
    }
}

/* ============================================
   RESPONSIVE — MOBILE (<640px)
   ============================================ */
@media (max-width: 640px) {
    /* Header */
    .header {
        flex-wrap: wrap;
        padding: 0 12px;
        gap: 8px;
        height: auto;
        min-height: 48px;
    }

    .header__toggle {
        display: block;
    }

    .header__nav {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 10;
        background: #16213e;
        border-top: 1px solid rgba(255,255,255,0.1);
        gap: 0;
        padding: 4px 0;
    }

    .header__nav.active {
        display: flex;
    }

    .nav-link {
        padding: 10px 16px;
        border-radius: 0;
        font-size: 14px;
    }

    .header__user {
        margin-left: auto;
        font-size: 13px;
    }

    /* Main */
    .main {
        padding: 12px;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header .btn {
        width: 100%;
    }

    /* Cards */
    .card {
        padding: 16px;
    }

    /* Stats grid — single column */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .stats-grid--3 {
        grid-template-columns: 1fr !important;
    }

    /* Tables — card view on mobile */
    .table { display: block; }
    .table thead { display: none; }
    .table tbody { display: block; }
    .table tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 12px;
        background: #fff;
    }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    .table td:last-child { border-bottom: none; }
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: #888;
        min-width: 100px;
    }

    /* Buttons — bigger touch targets */
    .btn--sm {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Auth */
    .auth-card {
        padding: 24px 16px;
    }

    /* Search */
    .search-box input {
        max-width: 100%;
    }

    /* Pagination */
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination__sizes {
        justify-content: center;
    }

    .pagination__nav {
        justify-content: center;
    }
}

/* === TOAST NOTIFICATIONS === */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    z-index: 1000;
    animation: toastSlideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast--success { background: #27ae60; }
.toast--error { background: #e74c3c; }
.toast--info { background: #3498db; }
.toast--warning { background: #f39c12; }

@keyframes toastSlideIn {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
