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

:root {
    --blue: #4285F4;
    --blue-hover: #3367D6;
    --red: #EA4335;
    --green: #34A853;
    --yellow: #FBBC05;
    --bg: #FFFFFF;
    --bg-sidebar: #F8F9FA;
    --text-primary: #202124;
    --text-secondary: #5F6368;
    --border: #DADCE0;
    --border-light: #E8EAED;
    --shadow: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --font: -apple-system, 'Segoe UI', 'Noto Sans SC', Roboto, sans-serif;
}

body {
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg);
    line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-sidebar);
}

.login-card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-form .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-form input:focus {
    border-color: var(--blue);
}

.login-error {
    color: var(--red);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--blue);
    color: white;
    width: 100%;
}
.btn-primary:hover { background: var(--blue-hover); }

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid var(--border);
}
.btn-danger:hover { background: #FEE; }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ========== Layout ========== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    padding: 20px 0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 24px 20px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 12px;
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-brand span {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.15s;
    text-decoration: none;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: #E8F0FE;
    color: var(--blue);
}

.sidebar-nav li a .icon {
    width: 20px;
    text-align: center;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 400;
}

/* ========== Stats Cards ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 400;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========== Table ========== */
.table-container {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
}

.toolbar input,
.toolbar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--blue);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-sidebar);
}

td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}

tr:hover td {
    background: #F8F9FA;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #E6F4EA; color: var(--green); }
.badge-danger { background: #FEE; color: var(--red); }
.badge-group { background: #E8F0FE; color: var(--blue); }
.badge-active { background: #E6F4EA; color: var(--green); }
.badge-disabled { background: #FEE; color: var(--red); }

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 32px;
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.modal input,
.modal select,
.modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.modal textarea { resize: vertical; min-height: 60px; }
.modal input:focus, .modal select:focus { border-color: var(--blue); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--blue);
    padding: 6px 12px;
    cursor: pointer;
}
.btn-text:hover { background: #E8F0FE; border-radius: 4px; }

.btn-text-danger {
    background: none;
    border: none;
    color: var(--red);
    padding: 6px 12px;
    cursor: pointer;
}
.btn-text-danger:hover { background: #FEE; border-radius: 4px; }

.btn-text-warn {
    background: none;
    border: none;
    color: #E37400;
    padding: 6px 12px;
    cursor: pointer;
}
.btn-text-warn:hover { background: #FEF7E0; border-radius: 4px; }

.action-cell {
    white-space: nowrap;
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-btns {
    display: flex;
    gap: 4px;
}

.pagination-btns button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    cursor: pointer;
    font-size: 13px;
}

.pagination-btns button:hover { background: var(--bg-sidebar); }
.pagination-btns button.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #323232;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 2000;
    display: none;
}

.toast.show { display: block; animation: fadeIn 0.3s; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== Recent Logins ========== */
.recent-logins {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
}

.recent-logins h3 {
    font-size: 16px;
    margin-bottom: 16px;
    font-weight: 500;
}

.log-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.log-item:last-child { border-bottom: none; }

.log-item .log-user {
    font-weight: 500;
    min-width: 100px;
}

.log-item .log-action {
    color: var(--text-secondary);
    flex: 1;
}

.log-item .log-time {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ========== Settings ========== */
.settings-section {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
}

.settings-form {
    max-width: 400px;
}

.settings-form .form-group {
    margin-bottom: 16px;
}

.settings-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.settings-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.settings-form input:focus {
    border-color: var(--blue);
}

.modal-card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 32px;
}

.modal-card h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.modal-card .form-group {
    margin-bottom: 16px;
}

.modal-card label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.modal-card input,
.modal-card select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.role-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.role-admin {
    background: #E8F0FE;
    color: var(--blue);
}

.role-bot {
    background: #E6F4EA;
    color: var(--green);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 10px 24px;
}

.btn-secondary:hover {
    background: var(--bg-sidebar);
}
