:root {
    --primary: #007AFF;
    --primary-hover: #0056b3;
    --bg-dark: #0a0a0c;
    --bg-card: #1c1c1e;
    --bg-sidebar: #161618;
    --text-main: #ffffff;
    --text-muted: #8e8e93;
    --border: #2c2c2e;
    --error: #ff453a;
    --success: #32d74b;
    --warning: #ffd60a;
}

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

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.full-height {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Auth Cards */
.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.login-card .btn-primary {
    width: 100%;
}

.logo {
    width: 150px;
    margin-bottom: 24px;
}

.logo-small {
    width: 100px;
    margin-bottom: 20px;
}

h1,
h2,
h3 {
    margin-bottom: 20px;
    font-weight: 600;
}

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

label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

input {
    width: 100%;
    background: #2c2c2e;
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 8px;
    color: white;
    font-size: 16px;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: auto;
    min-width: 120px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 20px;
    font-size: 16px;
    font-family: 'PP Neue Montreal', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #333;
    color: white;
    border: 1px solid #444;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-family: 'PP Neue Montreal', sans-serif;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: #444;
    color: #fff;
}

.btn-white {
    background: #ffffff;
    color: #000000;
    border: 1px solid #ffffff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-family: 'PP Neue Montreal', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-white:hover {
    background: #e0e0e0;
    border-color: #e0e0e0;
}

.btn-text {
    background: #333;
    color: white;
    border: 1px solid #444;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-family: 'PP Neue Montreal', sans-serif;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-text:hover {
    background: #444;
    color: #fff;
}

.error-msg {
    color: var(--error);
    font-size: 14px;
    margin-top: 16px;
}

/* Layout */
#mainView {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.nav-links {
    list-style: none;
    margin-top: 40px;
    flex-grow: 1;
}

.nav-links li {
    padding: 12px 16px;
    border-radius: 20px;
    margin-bottom: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.nav-links li .icon {
    margin-right: 12px;
}

.nav-links li:hover,
.nav-links li.active {
    background: #2c2c2e;
    color: white;
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.user-display-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.user-display-email {
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 20px;
    margin-left: 8px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.badge-super-admin {
    background: #ffffff;
    color: #000000;
    border: 1px solid #ffffff;
}

.badge-admin {
    background: transparent;
    color: #c0c0c0;
    /* Silver */
    border: 1px solid #333;
}

.content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

/* Tables */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.table-container {
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
}

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

th,
td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #2c2c2e;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

tr:hover td {
    background: #2c2c2e;
}

/* Overlays and Modals */
.overlay,
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.overlay.hidden,
.modal.hidden {
    display: none;
}

.overlay-content,
.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 20px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.overlay-content {
    max-width: 1000px;
    /* Detail view is wider */
}

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

.overlay-content header,
.modal-content header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-right: 40px;
    /* Make room for the absolute close button */
}

.btn-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-group {
    position: relative;
    width: 240px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.search-group input {
    padding-left: 36px;
    height: 40px;
}

.control-select {
    height: 40px;
    padding: 0 36px 0 12px;
    background: #2c2c2e;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    cursor: pointer;
}

.control-select:focus {
    outline: none;
    border-color: var(--primary);
}

.view-toggle {
    display: flex;
    background: #2c2c2e;
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--border);
    height: 40px;
}

.view-toggle button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    /* Matches parent height minus padding */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-toggle button:hover {
    color: white;
}

.view-toggle button.active {
    background: #444;
    color: white;
}

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.grid-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    border-color: #555;
    z-index: 1;
}

.card-preview {
    height: 160px;
    background: #111;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}

.card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-preview .no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.card-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.card-meta {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: #888;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.meta-row {
    display: flex;
    justify-content: space-between;
}

.card-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
}