/* ═══════════════════════════════════════════════
   Admin Panel — shared styles
   ═══════════════════════════════════════════════ */

/* ── Page shell ── */
.admin-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ── Header ── */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: #111827;
}

.admin-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

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

/* ── Back button ── */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-back:hover {
    color: #111827;
    border-color: #d1d5db;
    background: #f9fafb;
}

/* ── Action button ── */
.btn-action {
    padding: 0.4rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-action:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-action--primary {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.btn-action--primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}

.btn-action--danger {
    color: #dc2626;
    border-color: #fecaca;
}

.btn-action--danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

.btn-primary-action {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: #4f46e5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-primary-action:hover {
    background: #4338ca;
}

.btn-primary-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Loading ── */
.admin-loading {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #9ca3af;
    font-size: 0.875rem;
}

/* ── Alerts ── */
.admin-alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.admin-alert strong {
    font-weight: 600;
}

.admin-alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.admin-alert--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.admin-alert--warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.admin-alert--info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* ── Empty state ── */
.admin-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: #9ca3af;
}

.admin-empty__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 0.25rem;
}

.admin-empty__text {
    font-size: 0.8125rem;
    margin: 0;
}

/* ── Stats grid ── */
.stats-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stats-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.stats-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.stats-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

.stats-grid--5 {
    grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 640px) {
    .stats-grid--3,
    .stats-grid--4,
    .stats-grid--5 {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .stat-card {
        padding: 0.75rem 0.75rem;
        border-radius: 10px;
    }

    .stat-card__value {
        font-size: 1.25rem;
    }

    .stat-card__label {
        font-size: 0.625rem;
        margin-bottom: 0.15rem;
    }

    .stat-card__hint {
        font-size: 0.6875rem;
    }

    .nav-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .nav-card {
        padding: 0.75rem;
    }

    .nav-card__desc {
        font-size: 0.6875rem;
    }
}

/* ── Stat card ── */
.stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-align: center;
}

.stat-card--compact {
    padding: 0.75rem 1rem;
}

.stat-card__label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin-bottom: 0.25rem;
}

.stat-card__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.stat-card--compact .stat-card__value {
    font-size: 1.25rem;
}

.stat-card__hint {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.125rem;
}

/* ── Grid layout ── */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Panel ── */
.admin-panel {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.25rem;
}

.admin-grid .admin-panel {
    margin-bottom: 0;
}

.admin-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-panel__header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #111827;
}

.admin-panel__hint {
    font-size: 0.75rem;
    color: #9ca3af;
}

.admin-panel__desc {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: -0.5rem 0 1rem;
}

/* ── Admin link ── */
.admin-link {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #4f46e5;
    text-decoration: none;
}

.admin-link:hover {
    color: #4338ca;
    text-decoration: underline;
}

/* ── Table ── */
.table-wrap {
    overflow-x: auto;
    margin: 0 -0.25rem;
}

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

.admin-table thead th {
    text-transform: uppercase;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #9ca3af;
    padding: 0.5rem 0.75rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    text-align: left;
}

.admin-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #f9fafb;
    color: #374151;
    vertical-align: middle;
}

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

.admin-table tbody tr:hover {
    background: #fafbfc;
}

.admin-table tfoot td {
    padding: 0.75rem;
    border-top: 2px solid #f3f4f6;
    font-weight: 600;
    color: #111827;
}

.col-center {
    text-align: center;
}

.col-end {
    text-align: right;
}

.cell-name {
    font-weight: 600;
    color: #111827;
}

.cell-muted {
    color: #9ca3af;
}

/* ── Info list (key-value rows) ── */
.info-list {
    display: flex;
    flex-direction: column;
}

.info-list__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f9fafb;
    font-size: 0.875rem;
}

.info-list__row:last-child {
    border-bottom: none;
}

.info-list__label {
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 1rem;
}

.info-list__value {
    color: #111827;
    text-align: right;
    word-break: break-all;
}

/* ── Nav grid ── */
.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.nav-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.nav-card:hover {
    border-color: #4f46e5;
    background: #f5f3ff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.nav-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.nav-card__icon {
    color: #6366f1;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
}

.nav-card__desc {
    font-size: 0.75rem;
    color: #6b7280;
}

/* ── Status dot ── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.25rem;
}

.status-dot--ok {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-dot--off {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ── PG version ── */
.pg-version {
    display: block;
    font-size: 0.8125rem;
    color: #6b7280;
    word-break: break-all;
}

/* ── Form elements ── */
.form-field {
    margin-bottom: 1rem;
}

.form-field label,
.form-label-bold {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    color: #111827;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: white;
}

.form-input--sm {
    max-width: 120px;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

.form-row-inline {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.form-row-inline .form-field {
    margin-bottom: 0;
}

.form-field--buttons {
    display: flex;
    gap: 0.5rem;
}

/* ── Radio group ── */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.radio-option:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.radio-option--selected {
    border-color: #4f46e5;
    background: #f5f3ff;
}

.radio-option input[type="radio"] {
    accent-color: #4f46e5;
}

.radio-option__label {
    font-weight: 600;
    color: #111827;
}

.radio-option__desc {
    color: #6b7280;
    font-size: 0.8125rem;
}

/* ── Range ── */
.range-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.range-input {
    flex: 1;
    accent-color: #4f46e5;
}

.range-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    background: #f3f4f6;
    border-radius: 6px;
    color: #374151;
}

/* ── Key status ── */
.key-status-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.key-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-radius: 8px;
}

.key-status__name {
    font-weight: 600;
    color: #111827;
    font-size: 0.875rem;
    flex: 1;
}

.key-status__label {
    font-size: 0.8125rem;
    font-weight: 500;
}

.key-status__label--ok {
    color: #059669;
}

.key-status__label--off {
    color: #dc2626;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .admin-header {
        flex-direction: column;
    }

    .admin-table {
        font-size: 0.8125rem;
    }

    .admin-table thead th,
    .admin-table tbody td {
        padding: 0.5rem;
    }

    .form-row-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Team page ── */
.team-avatar-wrap {
    cursor: pointer;
    flex-shrink: 0;
    display: block;
}

.team-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.team-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.team-avatar__initials {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #9ca3af;
}

.team-avatar__spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: team-spin 0.6s linear infinite;
}

@keyframes team-spin {
    to { transform: rotate(360deg); }
}

.team-avatar__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
    border-radius: 50%;
}

.team-avatar-wrap:hover .team-avatar__overlay,
.team-avatar-wrap:focus-within .team-avatar__overlay {
    opacity: 1;
}

.team-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.team-icon-btn:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #f5f3ff;
}

.team-icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.team-icon-btn--danger:hover {
    border-color: #fca5a5;
    color: #dc2626;
    background: #fef2f2;
}

.team-chat-name-btn {
    background: none;
    border: none;
    border-bottom: 1px dashed #9ca3af;
    color: #374151;
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 0 2px 1px;
    transition: all 0.15s ease;
}

.team-chat-name-btn:hover {
    border-bottom-color: #4f46e5;
    color: #4f46e5;
}

/* ═══════════════════════════════════════════════
   Modern Buttons
   ═══════════════════════════════════════════════ */

.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 10px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-modern--primary {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.btn-modern--primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.btn-modern--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-modern--violet {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
}

.btn-modern--violet:hover {
    background: #6d28d9;
    border-color: #6d28d9;
    box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

.btn-modern--violet:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-modern--outline {
    background: #fff;
    color: #7c3aed;
    border-color: #c4b5fd;
}

.btn-modern--outline:hover {
    background: #f5f3ff;
    border-color: #7c3aed;
}

.btn-modern--ghost {
    background: transparent;
    color: #6b7280;
    border-color: #e5e7eb;
}

.btn-modern--ghost:hover {
    background: #f3f4f6;
    color: #374151;
}

/* ═══════════════════════════════════════════════
   Modern Modal Overlay & Container
   ═══════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    animation: modalOverlayIn 0.2s ease;
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-modern {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 32px;
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-modern__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.modal-modern__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-modern__icon--blue {
    background: #dbeafe;
    color: #2563eb;
}

.modal-modern__icon--violet {
    background: #ede9fe;
    color: #7c3aed;
}

.modal-modern__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    flex: 1;
}

.modal-modern__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.modal-modern__close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-modern__desc {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0 0 20px;
    line-height: 1.5;
}

.modal-modern__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
}

/* ═══════════════════════════════════════════════
   Modern Form Fields
   ═══════════════════════════════════════════════ */

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

.form-modern-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 480px) {
    .form-modern-row {
        grid-template-columns: 1fr;
    }
    .modal-modern {
        margin: 12px;
        padding: 20px;
    }
}

.form-modern-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 5px;
}

.form-modern-required {
    color: #ef4444;
}

.form-modern-hint {
    color: #9ca3af;
    font-weight: 400;
}

.form-modern-input,
.form-modern-select,
.form-modern-textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.875rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 9px;
    background: #fafafa;
    color: #111827;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.form-modern-input:focus,
.form-modern-select:focus,
.form-modern-textarea:focus {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-modern-input::placeholder,
.form-modern-textarea::placeholder {
    color: #c0c4cc;
}

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

.form-modern-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 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ═══════════════════════════════════════════════
   Modern Alert
   ═══════════════════════════════════════════════ */

.alert-modern {
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 0.8125rem;
    margin-bottom: 16px;
    line-height: 1.4;
}

.alert-modern--success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-modern--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ═══════════════════════════════════════════════
   Token Usage — analytics dashboard styles
   ═══════════════════════════════════════════════ */

/* ── Progress bar (budget cards) ── */
.tu-progress-wrap {
    margin-top: 0.375rem;
}

.tu-progress-bar {
    height: 4px;
    background: #f3f4f6;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.tu-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.tu-progress-fill--ok {
    background: #10b981;
}

.tu-progress-fill--warning {
    background: #f59e0b;
}

.tu-progress-fill--danger {
    background: #ef4444;
}

/* ── Period selector ── */
.tu-period-selector {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 0.25rem;
    width: fit-content;
}

.tu-period-btn {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tu-period-btn:hover {
    color: #374151;
}

.tu-period-btn--active {
    background: white;
    color: #111827;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

/* ── Daily bar chart ── */
.tu-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 160px;
    padding-bottom: 1.5rem;
    position: relative;
}

.tu-chart__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 0;
}

.tu-chart__bar-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.tu-chart__bar {
    width: 100%;
    max-width: 32px;
    background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
    border-radius: 3px 3px 0 0;
    min-height: 1px;
    position: relative;
    overflow: hidden;
    transition: height 0.3s ease;
}

.tu-chart__bar-prompt {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 0 0 0 0;
}

.tu-chart__col--today .tu-chart__bar {
    background: linear-gradient(180deg, #34d399 0%, #059669 100%);
}

.tu-chart__label {
    font-size: 0.5625rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    white-space: nowrap;
    text-align: center;
    position: absolute;
    bottom: 0;
}

.tu-chart-legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.tu-chart-legend__item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.tu-chart-legend__dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.tu-chart-legend__dot--prompt {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid #818cf8;
}

.tu-chart-legend__dot--completion {
    background: #4f46e5;
}

/* ── Hourly heatmap ── */
.tu-heatmap {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
}

.tu-heatmap__cell {
    aspect-ratio: 1;
    border-radius: 4px;
    background: color-mix(in srgb, #4f46e5 calc(var(--intensity) * 100%), #f3f4f6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.1s ease;
    min-height: 28px;
}

.tu-heatmap__cell:hover {
    transform: scale(1.15);
    z-index: 1;
}

.tu-heatmap__hour {
    font-size: 0.5625rem;
    font-weight: 600;
    color: color-mix(in srgb, white calc(var(--intensity) * 80%), #6b7280);
}

.tu-heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.6875rem;
    color: #9ca3af;
}

.tu-heatmap-legend__scale {
    display: flex;
    gap: 2px;
}

.tu-heatmap-legend__step {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: color-mix(in srgb, #4f46e5 calc(var(--intensity) * 100%), #f3f4f6);
}

/* ── Breakdown bars (services, models) ── */
.tu-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tu-breakdown-item__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.25rem;
}

.tu-breakdown-item__name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tu-breakdown-item__value {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.tu-breakdown-item__pct {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 400;
}

.tu-breakdown-item__bar {
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}

.tu-breakdown-item__fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #818cf8);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.tu-breakdown-item__bar--alt .tu-breakdown-item__fill,
.tu-breakdown-item__fill--alt {
    background: linear-gradient(90deg, #0891b2, #22d3ee);
}

.tu-breakdown-item__meta {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 0.125rem;
}

/* ── Today badge in table ── */
.tu-badge {
    display: inline-block;
    padding: 0.0625rem 0.375rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #ecfdf5;
    color: #059669;
    border-radius: 4px;
    margin-left: 0.375rem;
    vertical-align: middle;
}

.tu-row--today {
    background: #f0fdf4 !important;
}

.tu-row--today:hover {
    background: #ecfdf5 !important;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .tu-period-selector {
        width: 100%;
    }

    .tu-period-btn {
        flex: 1;
        text-align: center;
    }

    .tu-chart {
        height: 120px;
    }

    .tu-heatmap {
        grid-template-columns: repeat(12, 1fr);
    }

    .tu-heatmap__cell:nth-child(n+13) {
        /* second row on mobile */
    }
}

/* ═══════════════════════════════════════════════
   Task Selection page
   ═══════════════════════════════════════════════ */

.task-selection-page {
    max-width: 1600px;
}

.ts-student-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ts-student-selector label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
}

.ts-student-selector select {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    min-width: 250px;
}

.ts-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1rem;
    align-items: start;
}

.ts-panel {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.ts-panel--left {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 10rem);
    display: flex;
    flex-direction: column;
}

.ts-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.ts-panel__header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    color: #111827;
}

.ts-panel__actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.btn-action--sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-action--primary {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.btn-action--primary:hover {
    background: #1d4ed8;
}

.ts-task-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.ts-task-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

.ts-task-item:hover {
    background: #f9fafb;
}

.ts-task-item--selected {
    background: #eff6ff;
}

.ts-task-item input[type="checkbox"] {
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.ts-task-item__info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    min-width: 0;
}

.ts-task-item__title {
    font-size: 0.8125rem;
    color: #111827;
    word-break: break-word;
}

.ts-badge {
    display: inline-block;
    padding: 0.1rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 500;
    border-radius: 4px;
    background: #f3f4f6;
    color: #6b7280;
}

.ts-badge--analysis {
    background: #dcfce7;
    color: #166534;
}

.ts-badge--liked {
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
}

.ts-badge--disliked {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 600;
}

.ts-task-item__date {
    margin-left: auto;
    font-size: 0.6875rem;
    color: #9ca3af;
    white-space: nowrap;
}

.ts-filters {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.ts-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ts-filter-group > label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.ts-filter-chips {
    display: flex;
    gap: 0.25rem;
}

.ts-chip {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.ts-chip:hover {
    border-color: #9ca3af;
    background: #f3f4f6;
}

.ts-chip--active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.ts-chip--active:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.ts-empty {
    padding: 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: #9ca3af;
}

.ts-data-scroll {
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(100vh - 20rem);
}

.ts-task-block {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.ts-task-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ts-task-block h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: #111827;
}

.ts-section {
    margin-bottom: 1rem;
}

.ts-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #f3f4f6;
}

.ts-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

.ts-dl dt {
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.ts-dl dd {
    margin: 0;
    color: #111827;
}

.ts-pre {
    margin: 0;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f9fafb;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid #f3f4f6;
    max-height: 200px;
    overflow-y: auto;
}

.ts-pre--long {
    max-height: 300px;
}

.ts-pre--json {
    font-family: 'Courier New', monospace;
    font-size: 0.6875rem;
}

.ts-muted {
    font-size: 0.8125rem;
    color: #9ca3af;
    font-style: italic;
}

.ts-copy-msg {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    color: #166534;
    background: #f0fdf4;
    border-bottom: 1px solid #dcfce7;
}

.ts-paste-section {
    padding: 1rem;
    border-top: 2px solid #e5e7eb;
}

.ts-paste-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 0.5rem;
}

.ts-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    font-size: 0.8125rem;
    font-family: 'Courier New', monospace;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: vertical;
    box-sizing: border-box;
}

.ts-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

@media (max-width: 768px) {
    .ts-layout {
        grid-template-columns: 1fr;
    }

    .ts-panel--left {
        position: static;
        max-height: 300px;
    }
}

/* ═══════════════════════════════════════════════
   AI Suggestions table (admin/ai-suggestions)
   ═══════════════════════════════════════════════ */

.ais-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.ais-table thead th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.ais-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #111827;
    vertical-align: top;
}

.ais-row {
    cursor: pointer;
    transition: background 0.1s;
}

.ais-row:hover {
    background: #f9fafb;
}

.ais-row--expanded {
    background: #eff6ff;
}

.ais-cell--date {
    white-space: nowrap;
    color: #6b7280;
    font-size: 0.75rem;
}

.ais-cell--task {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ais-cell--summary {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6b7280;
}

.ais-detail-row td {
    padding: 0 !important;
    border-bottom: 2px solid #e5e7eb;
}

.ais-detail {
    padding: 1rem;
    background: #fafbfc;
}

.ais-detail__columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.ais-detail__col h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.ais-detail__label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.15rem;
}

.ais-detail__value {
    font-size: 0.8125rem;
    color: #111827;
    margin-bottom: 0.25rem;
}

.ais-detail__meta {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.75rem;
    color: #9ca3af;
}

@media (max-width: 768px) {
    .ais-detail__columns {
        grid-template-columns: 1fr;
    }

    .ais-table {
        font-size: 0.75rem;
    }
}
