body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
}

nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

nav .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    text-decoration: none;
}

nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

nav ul li a, nav ul li span {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    transition: background 0.15s;
}

nav ul li a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

nav .username {
    color: #94a3b8;
    margin-right: 0.5rem;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.3rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: #3B82F6;
    color: #fff;
}

.btn-primary:hover {
    background: #2563EB;
}

.btn-block {
    width: 100%;
    padding: 0.7rem;
}

.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: #EF4444;
    color: #fff;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-outline:hover {
    background: #f3f4f6;
}

.error-msg {
    color: #DC2626;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #FEF2F2;
    border-radius: 6px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.system-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.system-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.1);
}

.system-card .color-bar {
    height: 4px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.system-card .icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.system-card h3 {
    margin: 0 0 0.3rem;
    font-size: 1.1rem;
}

.system-card .base-url {
    font-size: 0.8rem;
    color: #9CA3AF;
    margin-bottom: 1rem;
}



h2 {
    margin: 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.3rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

th {
    background: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748B;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
}

tr:hover td {
    background: #f8fafc;
}

.empty-msg {
    text-align: center;
    color: #9CA3AF;
    padding: 3rem 1rem;
    font-size: 0.9rem;
}

.perm-grid {
    display: grid;
    grid-template-columns: 180px repeat(auto-fill, minmax(100px, 1fr));
    gap: 2px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.perm-header, .perm-cell {
    background: #fff;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.perm-header:first-child {
    justify-content: flex-start;
    font-weight: 600;
}

.perm-cell {
    cursor: pointer;
    transition: background 0.1s;
}

.perm-cell:hover {
    background: #f1f5f9;
}

.perm-cell.on {
    background: #D1FAE5;
    color: #065F46;
}

.perm-cell.off {
    background: #fff;
    color: #9CA3AF;
}

.select-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.select-group select {
    flex: 1;
    min-width: 140px;
    padding: 0.5rem 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

.modal-overlay.active {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    z-index: 1000;
    min-width: 380px;
    max-width: 90vw;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

.modal.active {
    display: block;
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.modal .form-group {
    margin-bottom: 0.8rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.2rem;
}

.auto-submit-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    text-align: center;
}

.auto-submit-page .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.auto-submit-page p {
    color: #64748B;
    font-size: 1rem;
}

.auto-submit-page .fallback-btn {
    margin-top: 1.5rem;
    display: none;
}

@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    .perm-grid {
        grid-template-columns: 120px repeat(auto-fill, minmax(70px, 1fr));
    }
}

