/**
 * TAK IT Portal - Admin Styles
 * Consolidated admin styling with theme tokens
 */

/* Theme Tokens */
:root {
    --bg: #0a0a0a;
    --surface: #1a1a1a;
    --surface-2: #252525;
    --border: #333;
    --text: #ffffff;
    --muted: #ccc;
    --accent: #00d4ff;
    --accent-hover: #00a8cc;
    --accent-2: #00a8cc;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
}

/* Admin Header */
.admin-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}

.admin-header .container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.admin-header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.admin-header .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-header .brand h1 {
    color: var(--accent);
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.admin-header .brand-sep {
    color: var(--border);
    font-size: 1.2rem;
    line-height: 1;
}

.admin-header .brand-section {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.admin-header .header-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.admin-header .nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 5px;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.admin-header .nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.admin-header .nav-link.active {
    background: rgba(0,212,255,0.12);
    color: var(--accent);
}

.nav-user-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--muted);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Page Layout */
.admin-main {
    padding: 1.75rem 0 3rem;
    font-size: 0.95rem;
    background: var(--bg);
    flex: 1;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Admin Content Scale */
.admin-content {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Admin Stats Cards */
.admin-stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.admin-stats-cards .summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: none;
}

.admin-stats-cards .summary-card:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
}

.admin-stats-cards .summary-card-icon {
    width: 36px;
    height: 36px;
    background: rgba(0,212,255,0.1);
    color: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-stats-cards .summary-card-content {
    flex: 1;
    min-width: 0;
}

.admin-stats-cards .summary-card-title,
.admin-stats-cards .summary-card-label {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-stats-cards .summary-card-value {
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.admin-content h1 {
    font-size: 1.8rem;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.admin-content h2 {
    font-size: 1.4rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.admin-content h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 0.75rem;
}

/* Page Header */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.page-title-section {
    flex: 1;
    min-width: 0;
}

.page-title {
    color: var(--text);
    margin: 0 0 0.3rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--muted);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    align-items: center;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: visible;
    transition: none;
}

.card:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.card-title {
    color: var(--muted);
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.card-body {
    padding: 1.25rem 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-height: 32px;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    min-height: 28px;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: #000;
    border-color: var(--warning);
}

.btn-warning:hover {
    background: #e0a800;
    border-color: #e0a800;
    transform: translateY(-1px);
}

/* Admin Table */
.admin-table-container,
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
    border: 1px solid var(--border);
    /* Allow horizontal scroll to escape card overflow:visible */
    position: relative;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0;
    font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
    padding: 0.7rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    line-height: 1.4;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}

/* Catalog table (6 cols: Name, Category, Scope, Status, Owner, Actions) */
.catalog-table th:nth-child(1),
.catalog-table td:nth-child(1) { /* Name */
    min-width: 200px;
    max-width: 280px;
}

.catalog-table th:nth-child(2),
.catalog-table td:nth-child(2) { /* Category */
    min-width: 110px;
    max-width: 150px;
    white-space: nowrap;
}

.catalog-table th:nth-child(3),
.catalog-table td:nth-child(3) { /* Scope */
    min-width: 90px;
    max-width: 110px;
    white-space: nowrap;
}

.catalog-table th:nth-child(4),
.catalog-table td:nth-child(4) { /* Status */
    min-width: 80px;
    max-width: 100px;
    white-space: nowrap;
}

.catalog-table th:nth-child(5),
.catalog-table td:nth-child(5) { /* Owner */
    min-width: 100px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-table th:nth-child(6),
.catalog-table td:nth-child(6) { /* Actions */
    min-width: 160px;
    width: 160px;
    white-space: nowrap;
}

.admin-table tbody tr {
    background: transparent;
    transition: background-color 0.2s ease;
}

.admin-table tbody tr:hover {
    background: var(--surface-2);
}

.admin-table td {
    vertical-align: middle;
}

.admin-table td:first-child {
    font-weight: 500;
}

/* ID sub-text inside name cell (catalog table) */
.app-id-sub {
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
    margin-top: 0.1rem;
}

/* Users Table Specific Column Widths */
.users-table .admin-table th:nth-child(1),
.users-table .admin-table td:nth-child(1) { /* Name */
    min-width: 200px;
    max-width: 250px;
}

.users-table .admin-table th:nth-child(2),
.users-table .admin-table td:nth-child(2) { /* Email */
    min-width: 180px;
    max-width: 220px;
}

.users-table .admin-table th:nth-child(3),
.users-table .admin-table td:nth-child(3) { /* Status */
    min-width: 80px;
    max-width: 100px;
    text-align: center;
}

.users-table .admin-table th:nth-child(4),
.users-table .admin-table td:nth-child(4) { /* Roles */
    min-width: 120px;
    max-width: 150px;
}

.users-table .admin-table th:nth-child(5),
.users-table .admin-table td:nth-child(5) { /* Department */
    min-width: 120px;
    max-width: 150px;
}

.users-table .admin-table th:nth-child(6),
.users-table .admin-table td:nth-child(6) { /* Last Login */
    min-width: 120px;
    max-width: 140px;
}

.users-table .admin-table th:nth-child(7),
.users-table .admin-table td:nth-child(7) { /* Actions */
    min-width: 140px;
    max-width: 160px;
}

/* App Name Cell */
.app-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-icon-mini {
    width: 20px;
    height: 20px;
    min-width: 20px;
    max-width: 20px;
    max-height: 20px;
    object-fit: contain;
    display: block;
    overflow: hidden;
    flex-shrink: 0;
}

.app-icon-abbr {
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: var(--bg);
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

/* Chips for roles and tags */
.role-chips,
.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.role-chips li,
.tag-chips li {
    background: var(--surface-2);
    color: var(--muted);
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
    font-size: 0.7rem;
    border: 1px solid var(--border);
}

.role-chips li {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent);
    border-color: rgba(0, 212, 255, 0.2);
}

.tag-chips li {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning);
    border-color: rgba(255, 193, 7, 0.2);
}

/* Status Badges */
.status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid;
}

.status-active {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success);
    border-color: rgba(40, 167, 69, 0.3);
}

.status-inactive {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
    border-color: rgba(220, 53, 69, 0.3);
}

.status-draft {
    background: rgba(255, 193, 7, 0.15);
    color: var(--warning);
    border-color: rgba(255, 193, 7, 0.3);
}

/* Action Buttons — table row actions */
.action-buttons {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: nowrap;
}

.action-buttons .btn,
.action-buttons .btn-sm,
.action-buttons button {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    white-space: nowrap;
    min-height: 28px;
    border-radius: 4px;
    margin: 0;
}

.action-buttons form {
    display: inline-flex;
    margin: 0;
}

/* Forms */
.form-container {
    max-width: 820px;
}

.form-value {
    padding: 0.6rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    opacity: 0.75;
    min-height: 38px;
    display: flex;
    align-items: center;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ccc' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.form-group input[readonly] {
    opacity: 0.65;
    cursor: not-allowed;
}

.form-help {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
    line-height: 1.4;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.95rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--accent);
}

.required {
    color: var(--danger);
    font-weight: 600;
}

.optional {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.8em;
}

/* Form Layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.form-actions .btn-danger {
    margin-left: auto;
}

/* Form Sections */
.form-section {
    margin-bottom: 2.25rem;
    padding-bottom: 2.25rem;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-header {
    margin-bottom: 1.25rem;
}

.form-section-header h3 {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin: 0 0 0.3rem 0;
}

.form-section-header p {
    color: var(--muted);
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.8;
}


/* Button accessibility */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

button.btn {
    font-family: inherit;
}

button.btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1000;
}

.flash-message {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    position: relative;
    border-left: 4px solid;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.flash-content {
    flex: 1;
    margin-right: 1rem;
    line-height: 1.4;
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.7;
    flex-shrink: 0;
}

.flash-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.flash-success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
    border-left-color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-left: 4px solid #28a745;
}

.flash-error {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-left: 4px solid #dc3545;
}

.flash-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-left: 4px solid #ffc107;
}

.flash-info {
    background: rgba(0, 212, 255, 0.2);
    color: var(--accent);
    border: 1px solid rgba(0, 212, 255, 0.3);
}

/* Role Badges */
.role-list {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.role-badge {
    background: var(--surface-2);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.role-badge.admin {
    background: rgba(0, 212, 255, 0.2);
    color: var(--accent);
    border-color: rgba(0, 212, 255, 0.3);
}

.role-badge.super_admin {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger);
    border-color: rgba(220, 53, 69, 0.3);
}

.role-badge.user {
    background: rgba(108, 117, 125, 0.2);
    color: #6c757d;
    border-color: rgba(108, 117, 125, 0.3);
}

.role-badge.org_admin {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
    border-color: rgba(255, 193, 7, 0.3);
}

/* Type Badges */
.type-badge {
    background: var(--surface-2);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.type-badge.internal {
    background: rgba(0, 212, 255, 0.2);
    color: var(--accent);
    border-color: rgba(0, 212, 255, 0.3);
}

.type-badge.external {
    background: rgba(25, 135, 84, 0.2);
    color: #198754;
    border-color: rgba(25, 135, 84, 0.3);
}

.type-badge.partner {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border-color: rgba(255, 193, 7, 0.3);
}

.type-badge.customer {
    background: rgba(111, 66, 193, 0.2);
    color: #6f42c1;
    border-color: rgba(111, 66, 193, 0.3);
}

/* Organization Details */
.organization-details {
    display: grid;
    gap: 1rem;
}

.detail-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.detail-label {
    font-weight: 600;
    min-width: 140px;
    color: var(--text-muted);
}

.detail-value {
    flex: 1;
    color: var(--text);
}

.organization-name {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.organization-id {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Organization view — apps section */
.org-apps-scroll {
    max-height: 420px;
    overflow-y: auto;
}

.org-section-divider {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 1.5rem 0 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.org-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.org-section-note {
    font-size: 0.8rem;
    color: var(--muted);
    opacity: 0.65;
}

/* Diagnostics action list */
.diag-action-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.diag-action-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

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

.diag-action-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
}

.diag-action-info strong {
    font-size: 0.9rem;
    color: var(--text);
}

.diag-action-info span {
    font-size: 0.8rem;
    color: var(--muted);
}

.diag-cmd {
    font-size: 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
    font-family: monospace;
    max-width: 480px;
    overflow-x: auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-title {
    color: var(--text);
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
}

.empty-state-description {
    color: var(--muted);
    margin: 0 0 2rem 0;
}

.empty-state-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Breadcrumbs */
.breadcrumbs {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.breadcrumb-link {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumb-link:hover {
    color: var(--accent);
}

.breadcrumb-current {
    color: var(--text);
}

.breadcrumb-separator {
    color: var(--muted);
    margin: 0 0.5rem;
}

/* Admin App View Styles */
.app-hero {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.app-hero-icon {
    width: 64px;
    height: 64px;
    background: rgba(0,212,255,0.12);
    color: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    flex-shrink: 0;
    border: 1px solid rgba(0,212,255,0.2);
}

.app-hero-icon img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    border-radius: 6px;
}

.app-hero-content {
    flex: 1;
    min-width: 0;
}

.app-hero-header {
    margin-bottom: 0.5rem;
}

.app-hero-header h1 {
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.01em;
}

.app-hero-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.app-hero-description {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0.5rem 0 0 0;
}

.app-hero-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Status and Category Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.status-inactive {
    background: rgba(108, 117, 125, 0.2);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.3);
}

.status-draft {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.category-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--accent);
    border: 1px solid var(--border);
}

/* Section sub-labels inside cards */
.section-sublabel {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    margin: 0 0 0.75rem;
    line-height: 1.5;
}

h4.section-sublabel {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    opacity: 0.8;
}

/* Scope Badges */
.scope-global {
    background: rgba(0, 212, 255, 0.12);
    color: var(--accent);
    border: 1px solid rgba(0, 212, 255, 0.25);
}

.scope-org {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.scope-personal {
    background: rgba(234, 179, 8, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(234, 179, 8, 0.25);
}

/* Tag Lists */
.tag-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: var(--surface-2);
    color: var(--text);
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.app-icon-large {
    width: 80px;
    height: 80px;
    min-width: 80px;
    background: var(--accent);
    color: var(--bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    flex-shrink: 0;
    overflow: hidden;
}

.app-icon-large img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-info {
    flex: 1;
    min-width: 0;
}

.app-info h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text);
    font-size: 1.5rem;
}

.app-info p {
    margin: 0 0 1rem 0;
    color: var(--muted);
    line-height: 1.4;
}

.app-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

.info-item {
    background: var(--surface-2);
    padding: 0.875rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.info-item label {
    display: block;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-item span,
.info-item code {
    color: var(--text);
    font-size: 0.9rem;
    word-break: break-all;
}

.url-link {
    color: var(--accent);
    text-decoration: none;
}

.url-link:hover {
    text-decoration: underline;
}

.empty {
    color: var(--muted);
    font-style: italic;
}

.notes-content {
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .page-header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .page-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .admin-header .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .admin-header .header-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .admin-table {
        min-width: 700px;
    }
    
    .app-header {
        flex-direction: column;
        text-align: center;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .admin-table {
        min-width: 800px;
    }
}

/* Token Input Styles */
.token-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-height: 44px;
    cursor: text;
    transition: border-color 0.2s ease;
}

.token-input:focus-within {
    border-color: var(--accent);
    outline: none;
}

.token-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.token-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
}

.token-chip-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    margin: 0;
    font-size: 1.1rem;
    line-height: 1;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.token-chip-remove:hover {
    color: var(--text);
    background: var(--danger);
}

.token-input-field {
    flex: 1;
    min-width: 120px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 0.875rem;
    padding: 4px 0;
    margin: 0;
}

.token-input-field::placeholder {
    color: var(--muted);
}

.token-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.token-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.token-suggestion:last-child {
    border-bottom: none;
}

.token-suggestion:hover,
.token-suggestion.active {
    background: var(--surface-2);
    color: var(--accent);
}

/* Position context for token inputs */
.form-group {
    position: relative;
}

/* Password toggle button */
.password-toggle {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s ease;
}

.password-toggle:hover {
    color: var(--text);
}

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input[type="password"],
.password-input-wrapper input[type="text"] {
    padding-right: 2.5rem;
}

/* ============================================================
   Admin Toolbar & Filter Grid
   ============================================================ */

.admin-toolbar {
    margin-bottom: 0.75rem;
}

/* Two-row catalog toolbar */
.admin-toolbar--catalog {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.admin-toolbar-search {
    display: flex;
}

.admin-toolbar-search .search-input--primary {
    flex: 1;
    width: 100%;
    max-width: none;
    font-size: 0.875rem;
    padding: 0.55rem 0.85rem;
    height: 38px;
}

.admin-toolbar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.admin-toolbar-actions {
    display: flex;
    gap: 0.4rem;
    margin-left: auto;
}

.admin-filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.admin-filter-grid .search-input {
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 320px;
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
    height: 36px;
}

.admin-filter-grid--compact .search-input {
    max-width: 240px;
}

/* ============================================================
   Bulk Action Bar (v2.8.0)
   ============================================================ */
.bulk-action-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

.bulk-action-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.bulk-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.bulk-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    flex-wrap: wrap;
}

.bulk-form .filter-select {
    min-width: 160px;
}

.bulk-checkbox-col {
    width: 40px;
    text-align: center;
    padding-left: 0.75rem !important;
    padding-right: 0.25rem !important;
}

.bulk-checkbox-col input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Table row hover highlight when bulk selecting */
tr:has(.app-checkbox:checked) {
    background: rgba(76, 175, 80, 0.08) !important;
}

.filter-select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    padding: 0.45rem 0.65rem;
    height: 36px;
    min-width: 120px;
    cursor: pointer;
    font-family: inherit;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0,212,255,0.12);
}

.filter-select--narrow {
    min-width: 90px;
}

/* ============================================================
   Scrollable table body with sticky header
   ============================================================ */

.admin-table-scroll {
    max-height: 420px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.admin-table-scroll--sm {
    max-height: 260px;
}

.admin-table-scroll table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2, var(--surface));
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    white-space: nowrap;
}

.admin-table-scroll tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}

.pagination-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pagination-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid var(--accent);
    border-radius: 5px;
    background: rgba(0,212,255,0.12);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
}

.pagination-ellipsis {
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0 0.25rem;
}

/* ============================================================
   Count / result line
   ============================================================ */

.count-muted {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.count-muted span {
    opacity: 0.7;
}

/* ============================================================
   Compact section header (title + action button on one line)
   ============================================================ */

.compact-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.compact-section-header span {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   Muted table cell value
   ============================================================ */

.td-muted {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ============================================================
   Apps management section (org-form app assignment panel)
   ============================================================ */

.apps-management-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
}

.apps-management-header {
    margin-bottom: 1.25rem;
}

.apps-management-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.35rem 0;
    text-transform: none;
    letter-spacing: 0;
}

.apps-management-header p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

/* ============================================================
   Action buttons — prevent messy wrapping in table cells
   ============================================================ */

.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    align-items: center;
}

/* ============================================================
   Search input base refinement
   ============================================================ */

.search-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0,212,255,0.12);
}

.search-input::placeholder {
    color: var(--muted);
    opacity: 0.75;
}
