/* ============================================================
   GyanGuru Monitor · Complete Stylesheet
   Version 3.1 – Final (with favicon support)
   Premium UI · Light & Dark Theme
   ============================================================ */

/* ----- CSS Variables (Light Theme) ----- */
:root {
    --gg-bg: #f6f8fc;
    --gg-surface: #ffffff;
    --gg-surface-2: #f1f4f9;
    --gg-border: #e2e8f0;
    --gg-text: #0b1a2e;
    --gg-text-secondary: #4b5a6e;
    --gg-text-muted: #8b9ab0;
    --gg-primary: #4f46e5;
    --gg-primary-hover: #4338ca;
    --gg-primary-subtle: #eef0ff;
    --gg-success: #0f973d;
    --gg-success-subtle: #e6f7ed;
    --gg-danger: #dc2626;
    --gg-danger-subtle: #fde8e8;
    --gg-warning: #d97706;
    --gg-warning-subtle: #fef6e6;
    --gg-info: #0e7bcd;
    --gg-info-subtle: #e6f0fa;
    --gg-sidebar-bg: #ffffff;
    --gg-sidebar-border: #e2e8f0;
    --gg-shadow: 0 4px 12px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
    --gg-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --gg-radius: 12px;
    --gg-radius-sm: 8px;
    --gg-transition: 0.25s ease;
}

/* ----- Dark Theme Variables ----- */
[data-bs-theme="dark"] {
    --gg-bg: #0e121b;
    --gg-surface: #181e2b;
    --gg-surface-2: #1f2737;
    --gg-border: #2c3548;
    --gg-text: #edf2f9;
    --gg-text-secondary: #94a3b8;
    --gg-text-muted: #5a6b84;
    --gg-primary: #818cf8;
    --gg-primary-hover: #6d76e6;
    --gg-primary-subtle: #1e1d3a;
    --gg-success: #34d399;
    --gg-success-subtle: #0a2a1e;
    --gg-danger: #f87171;
    --gg-danger-subtle: #2a1215;
    --gg-warning: #fbbf24;
    --gg-warning-subtle: #2a1f0a;
    --gg-info: #60a5fa;
    --gg-info-subtle: #1a263a;
    --gg-sidebar-bg: #131a26;
    --gg-sidebar-border: #2c3548;
    --gg-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --gg-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

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

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gg-bg);
    color: var(--gg-text);
    transition: background var(--gg-transition), color var(--gg-transition);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

img {
    max-width: 100%;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--gg-border);
    border-radius: 20px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gg-text-muted);
}

/* ----- Selection ----- */
::selection {
    background: var(--gg-primary-subtle);
    color: var(--gg-primary);
}

/* ============================================================
   SIDEBAR – width 290px, centered branding
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 290px;
    height: 100vh;
    background: var(--gg-sidebar-bg);
    border-right: 1px solid var(--gg-sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 1.75rem 1.5rem;
    z-index: 1030;
    transition: width var(--gg-transition), transform var(--gg-transition),
                background var(--gg-transition), border-color var(--gg-transition);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ----- Branding (centered) ----- */
.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding-bottom: 1.75rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--gg-border);
    transition: all var(--gg-transition);
}

.brand-logo {
    height: 128px;
    width: auto;
    transition: height var(--gg-transition);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
    transition: opacity var(--gg-transition), transform var(--gg-transition);
}

.brand-name {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    color: var(--gg-text);
}

.brand-subtitle {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--gg-text-muted);
    letter-spacing: 0.02em;
    margin-top: 1px;
}

/* ----- Sidebar Collapsed State ----- */
.sidebar.collapsed {
    width: 72px;
    padding: 1.75rem 0.75rem;
}

.sidebar.collapsed .brand-text {
    display: none;
}

.sidebar.collapsed .brand-logo {
    height: 56px;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    gap: 0;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 0.7rem 0;
}

.sidebar.collapsed .sidebar-nav a i {
    font-size: 1.4rem;
    margin: 0;
}

.sidebar.collapsed .sidebar-nav a span {
    display: none;
}

.sidebar.collapsed .sidebar-footer .version,
.sidebar.collapsed .sidebar-footer .copyright {
    display: none;
}

.sidebar.collapsed .coming-badge {
    display: none;
}

/* Tooltip on hover when collapsed */
.sidebar.collapsed .sidebar-nav a {
    position: relative;
}

.sidebar.collapsed .sidebar-nav a:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--gg-surface);
    color: var(--gg-text);
    padding: 0.25rem 0.75rem;
    border-radius: var(--gg-radius-sm);
    border: 1px solid var(--gg-border);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--gg-shadow);
    z-index: 100;
    pointer-events: none;
}

/* ----- Sidebar Navigation ----- */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0.7rem 1rem;
    border-radius: var(--gg-radius-sm);
    color: var(--gg-text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
}

.sidebar-nav a i {
    font-size: 1.2rem;
    width: 1.6rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav a span {
    white-space: nowrap;
    transition: opacity var(--gg-transition);
}

.sidebar-nav a:hover {
    background: var(--gg-primary-subtle);
    color: var(--gg-primary);
}

.sidebar-nav a.active {
    background: var(--gg-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.sidebar-nav a.active i {
    color: #fff;
}

/* Coming Soon badges */
.coming-soon {
    position: relative;
}

.coming-badge {
    font-size: 0.55rem;
    font-weight: 600;
    background: var(--gg-primary-subtle);
    color: var(--gg-primary);
    padding: 0.05rem 0.4rem;
    border-radius: 10px;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
    white-space: nowrap;
}

/* ----- Sidebar Footer ----- */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--gg-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-size: 0.7rem;
    color: var(--gg-text-muted);
    transition: all var(--gg-transition);
}

.sidebar-footer .version {
    font-weight: 600;
}

.sidebar-footer .copyright {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* ============================================================
   MAIN CONTENT – adjust for sidebar width
   ============================================================ */
.main-content {
    margin-left: 290px;
    padding: 1.5rem 2rem 1rem;
    min-height: 100vh;
    transition: margin var(--gg-transition);
    display: flex;
    flex-direction: column;
}

/* ============================================================
   HEADER – no duplicate branding, clean and minimal
   ============================================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0 0.75rem 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--gg-border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gg-text);
    padding: 0.2rem 0.1rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    color: var(--gg-primary);
}

.sidebar-toggle i {
    transition: transform 0.25s ease;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--gg-text);
    white-space: nowrap;
}

/* ----- Header Brand (visible on tablet/mobile where the sidebar is
   off-canvas by default, so GyanGuru branding is always on screen) ----- */
.header-brand {
    display: none;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo {
    height: 34px;
    width: auto;
}

.header-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gg-text);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* ----- Header Right ----- */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.header-right .search-wrapper {
    position: relative;
}

.header-right .search-wrapper input {
    width: 200px;
    padding: 0.4rem 0.4rem 0.4rem 2rem;
    border-radius: var(--gg-radius-sm);
    border: 1px solid var(--gg-border);
    background: var(--gg-surface);
    color: var(--gg-text);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.header-right .search-wrapper input:focus {
    border-color: var(--gg-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.header-right .search-wrapper input::placeholder {
    color: var(--gg-text-muted);
}

.header-right .search-wrapper i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gg-text-muted);
    font-size: 0.9rem;
}

.header-right .form-select {
    background-color: var(--gg-surface);
    color: var(--gg-text);
    border-color: var(--gg-border);
    font-size: 0.8rem;
    padding: 0.35rem 1.8rem 0.35rem 0.7rem;
    min-width: 100px;
    border-radius: var(--gg-radius-sm);
}

.header-right .form-select:focus {
    border-color: var(--gg-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.header-time {
    font-size: 0.8rem;
    color: var(--gg-text-muted);
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.btn-dark-mode {
    background: none;
    border: none;
    color: var(--gg-text-secondary);
    font-size: 1.2rem;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    transition: color 0.2s;
    border-radius: var(--gg-radius-sm);
}

.btn-dark-mode:hover {
    color: var(--gg-primary);
    background: var(--gg-primary-subtle);
}

.user-avatar {
    font-size: 1.6rem;
    color: var(--gg-text-muted);
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar i {
    transition: color 0.2s;
}

.user-avatar:hover i {
    color: var(--gg-primary);
}

/* ============================================================
   NOTIFICATION STRIP
   ============================================================ */
.notification-strip {
    background: var(--gg-surface);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius-sm);
    padding: 0.6rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--gg-shadow);
    transition: all var(--gg-transition);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--gg-text);
}

.notification-icon {
    font-size: 1.1rem;
}

.notification-text {
    flex: 1;
}

.notification-strip.alert {
    border-left: 4px solid var(--gg-danger);
}

.notification-strip.info {
    border-left: 4px solid var(--gg-success);
}

/* ============================================================
   RECENT CHANGES (Critical Updates)
   ============================================================ */
.critical-updates {
    background: var(--gg-surface);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--gg-shadow);
    transition: all var(--gg-transition);
}

.critical-updates:hover {
    border-color: var(--gg-primary);
}

.critical-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.critical-icon {
    color: var(--gg-primary);
    font-size: 1.2rem;
}

.critical-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gg-text);
}

.critical-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.7rem;
    border-radius: 20px;
    background: var(--gg-primary-subtle);
    color: var(--gg-primary);
    margin-left: auto;
}

.critical-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.critical-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.5rem 0.75rem;
    background: var(--gg-surface-2);
    border-radius: var(--gg-radius-sm);
    border-left: 3px solid var(--gg-danger);
    transition: background var(--gg-transition);
}

.critical-item:hover {
    background: var(--gg-primary-subtle);
}

.critical-item .critical-site {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gg-text);
}

.critical-item .critical-category {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--gg-text-muted);
    background: var(--gg-surface);
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.critical-item .critical-summary {
    font-size: 0.8rem;
    color: var(--gg-text-secondary);
    flex: 1;
}

.critical-item .critical-time {
    font-size: 0.7rem;
    color: var(--gg-text-muted);
    white-space: nowrap;
}

.critical-loading {
    font-size: 0.85rem;
    color: var(--gg-text-muted);
    padding: 0.5rem 0;
}

.critical-empty {
    font-size: 0.85rem;
    color: var(--gg-text-muted);
    padding: 0.5rem 0;
}

.spinner {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--gg-surface);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--gg-shadow);
    transition: all var(--gg-transition);
}

.stat-card:hover {
    border-color: var(--gg-primary);
    box-shadow: var(--gg-shadow-lg);
    transform: translateY(-2px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.2;
    color: var(--gg-text);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gg-text-muted);
}

.stat-trend {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gg-text-muted);
    margin-top: 1px;
}

.stat-trend.up {
    color: var(--gg-success);
}
.stat-trend.down {
    color: var(--gg-danger);
}
.stat-trend.neutral {
    color: var(--gg-text-muted);
}

/* ============================================================
   QUICK ACTIONS BAR
   ============================================================ */
.quick-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gg-surface);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius-sm);
    box-shadow: var(--gg-shadow);
    transition: all var(--gg-transition);
}

.quick-actions .btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: var(--gg-radius-sm);
    transition: all var(--gg-transition);
}

.quick-actions .btn-primary {
    background: var(--gg-primary);
    border: none;
    color: #fff;
}

.quick-actions .btn-primary:hover {
    background: var(--gg-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.quick-actions .btn-outline-secondary {
    border-color: var(--gg-border);
    color: var(--gg-text-secondary);
}

.quick-actions .btn-outline-secondary:hover {
    border-color: var(--gg-primary);
    color: var(--gg-primary);
    background: var(--gg-primary-subtle);
}

.quick-actions .btn-outline-warning {
    border-color: var(--gg-warning);
    color: var(--gg-warning);
}

.quick-actions .btn-outline-warning:hover {
    background: var(--gg-warning-subtle);
}

.quick-actions .btn-outline-success {
    border-color: var(--gg-success);
    color: var(--gg-success);
}

.quick-actions .btn-outline-success:hover {
    background: var(--gg-success-subtle);
}

.quick-actions .btn-outline-info {
    border-color: var(--gg-info);
    color: var(--gg-info);
}

.quick-actions .btn-outline-info:hover {
    background: var(--gg-info-subtle);
}

.refresh-control {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.refresh-control label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gg-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.refresh-control .form-select {
    background-color: var(--gg-surface-2);
    color: var(--gg-text);
    border-color: var(--gg-border);
    font-size: 0.75rem;
    padding: 0.2rem 1.8rem 0.2rem 0.5rem;
    min-width: 80px;
    border-radius: var(--gg-radius-sm);
}

.refresh-control .form-select:focus {
    border-color: var(--gg-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ============================================================
   TABLE CONTAINER
   ============================================================ */
.table-container {
    background: var(--gg-surface);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius);
    padding: 1.25rem 0 0.25rem 0;
    box-shadow: var(--gg-shadow);
    transition: all var(--gg-transition);
    overflow: hidden;
    flex: 1;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem 1rem 1.5rem;
}

.table-title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    color: var(--gg-text);
}

.site-count {
    font-size: 0.75rem;
    color: var(--gg-text-muted);
    background: var(--gg-surface-2);
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-weight: 500;
}

/* ----- Table Styles ----- */
.table {
    margin: 0;
    color: var(--gg-text);
}

.table thead th {
    background: var(--gg-surface-2);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gg-text-muted);
    border-bottom: 1px solid var(--gg-border);
    padding: 0.65rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--gg-border);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--gg-transition);
    cursor: default;
}

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

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

/* ----- Pin button ----- */
.pin-btn {
    background: none;
    border: none;
    color: var(--gg-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.1rem 0.2rem;
    transition: color 0.2s, transform 0.2s;
}
.pin-btn:hover {
    color: var(--gg-primary);
    transform: scale(1.1);
}
.pin-btn.pinned {
    color: #e74c3c;
    transform: scale(1.15);
}

/* ----- Category badge ----- */
.category-badge {
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--gg-primary-subtle);
    color: var(--gg-primary);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

/* ----- Favicon in table ----- */
.favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
    object-fit: contain;
    background: var(--gg-surface);
}

/* ----- Table cells ----- */
.table .site-name {
    font-weight: 600;
    color: var(--gg-text);
}

.table .site-url {
    font-size: 0.75rem;
    color: var(--gg-text-muted);
    display: block;
    font-family: 'Inter', monospace;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .site-url a {
    color: var(--gg-text-muted);
    text-decoration: none;
}

.table .site-url a:hover {
    color: var(--gg-primary);
    text-decoration: underline;
}

/* ----- Status Badges ----- */
.badge-status {
    font-weight: 500;
    font-size: 0.7rem;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    text-transform: capitalize;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-monitoring {
    background: var(--gg-success-subtle);
    color: var(--gg-success);
}

.badge-issue {
    background: var(--gg-danger-subtle);
    color: var(--gg-danger);
}

.badge-paused {
    background: var(--gg-surface-2);
    color: var(--gg-text-muted);
}

.badge-unknown {
    background: var(--gg-surface-2);
    color: var(--gg-text-muted);
}

/* ----- Type Badge (human‑readable) ----- */
.type-badge {
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--gg-surface-2);
    color: var(--gg-text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ----- Action Buttons ----- */
.action-btns {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.action-btns .btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border-radius: var(--gg-radius-sm);
    border: 1px solid var(--gg-border);
    background: transparent;
    color: var(--gg-text-secondary);
    transition: all var(--gg-transition);
    line-height: 1.4;
}

.action-btns .btn:hover {
    background: var(--gg-primary-subtle);
    color: var(--gg-primary);
    border-color: var(--gg-primary);
}

.action-btns .btn-outline-danger:hover {
    background: var(--gg-danger-subtle);
    color: var(--gg-danger);
    border-color: var(--gg-danger);
}

.action-btns .btn-outline-success:hover {
    background: var(--gg-success-subtle);
    color: var(--gg-success);
    border-color: var(--gg-success);
}

.action-btns .btn-outline-warning:hover {
    background: var(--gg-warning-subtle);
    color: var(--gg-warning);
    border-color: var(--gg-warning);
}

.action-btns .btn-outline-info:hover {
    background: var(--gg-info-subtle);
    color: var(--gg-info);
    border-color: var(--gg-info);
}

/* ----- Sort Icon ----- */
.sort-icon {
    opacity: 0.3;
    font-size: 0.7rem;
}

/* ============================================================
   EMPTY & LOADING STATES
   ============================================================ */
#emptyState i {
    display: block;
}

#emptyState h5 {
    color: var(--gg-text);
}

#emptyState p {
    color: var(--gg-text-muted);
}

#emptyState .btn-primary {
    background: var(--gg-primary);
    border: none;
}

#emptyState .btn-primary:hover {
    background: var(--gg-primary-hover);
}

#loadingState p {
    color: var(--gg-text-muted);
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
    margin-top: 2rem;
    padding: 1rem 0 0.5rem;
    border-top: 1px solid var(--gg-border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--gg-text-muted);
    background: transparent;
}

.app-footer .footer-divider {
    color: var(--gg-border);
}

.app-footer span {
    opacity: 0.8;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
    background: var(--gg-surface);
    color: var(--gg-text);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius);
    box-shadow: var(--gg-shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--gg-border);
    padding: 1rem 1.5rem;
}

.modal-header .btn-close {
    filter: invert(0.4);
}

[data-bs-theme="dark"] .modal-header .btn-close {
    filter: invert(0.8);
}

.modal-footer {
    border-top: 1px solid var(--gg-border);
    padding: 1rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-title {
    font-weight: 700;
}

.modal .form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--gg-text-secondary);
}

.modal .form-control,
.modal .form-select {
    background: var(--gg-surface-2);
    border: 1px solid var(--gg-border);
    color: var(--gg-text);
    border-radius: var(--gg-radius-sm);
    transition: all var(--gg-transition);
}

.modal .form-control:focus,
.modal .form-select:focus {
    border-color: var(--gg-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background: var(--gg-surface);
}

.modal .form-text {
    color: var(--gg-text-muted);
    font-size: 0.75rem;
}

.modal .btn-primary {
    background: var(--gg-primary);
    border: none;
    font-weight: 600;
}
.modal .btn-primary:hover {
    background: var(--gg-primary-hover);
}

.modal .btn-secondary {
    background: var(--gg-surface-2);
    border: 1px solid var(--gg-border);
    color: var(--gg-text-secondary);
}
.modal .btn-secondary:hover {
    background: var(--gg-border);
    color: var(--gg-text);
}

.modal .btn-danger {
    background: var(--gg-danger);
    border: none;
}
.modal .btn-danger:hover {
    background: #b91c1c;
}

/* Advanced toggle button */
#advancedToggle {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-color: var(--gg-border);
    color: var(--gg-text-secondary);
}
#advancedToggle:hover {
    border-color: var(--gg-primary);
    color: var(--gg-primary);
    background: var(--gg-primary-subtle);
}

/* ----- History Modal Detail Grid ----- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
    margin: 1rem 0 1.5rem;
    padding: 1rem;
    background: var(--gg-surface-2);
    border-radius: var(--gg-radius-sm);
}

.detail-grid .item .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gg-text-muted);
    display: block;
}

.detail-grid .item .value {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gg-text);
    word-break: break-word;
}

.detail-grid .item .value a {
    color: var(--gg-primary);
    text-decoration: none;
}
.detail-grid .item .value a:hover {
    text-decoration: underline;
}

/* ----- History List ----- */
.history-list {
    max-height: 350px;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--gg-border);
    margin-bottom: 0.5rem;
    background: var(--gg-surface-2);
    border-radius: var(--gg-radius-sm);
    transition: background var(--gg-transition);
}

.history-item:hover {
    background: var(--gg-primary-subtle);
}

.history-item .time {
    font-size: 0.7rem;
    color: var(--gg-text-muted);
}

.history-item .summary {
    font-size: 0.85rem;
    margin-top: 0.2rem;
    font-weight: 500;
}

.history-item .summary .added {
    color: var(--gg-success);
}

.history-item .summary .removed {
    color: var(--gg-danger);
    text-decoration: line-through;
}

.history-item .diff-preview {
    font-size: 0.75rem;
    color: var(--gg-text-secondary);
    margin-top: 0.3rem;
    font-family: 'Inter', monospace;
    background: var(--gg-surface);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--gg-border);
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container .toast {
    background: var(--gg-surface);
    color: var(--gg-text);
    border: 1px solid var(--gg-border);
    border-radius: var(--gg-radius-sm);
    box-shadow: var(--gg-shadow-lg);
    font-size: 0.9rem;
    padding: 0;
    min-width: 280px;
}

.toast-container .toast .toast-body {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.toast-container .toast i {
    font-size: 1.2rem;
}

.toast-container .toast .toast-success i {
    color: var(--gg-success);
}
.toast-container .toast .toast-danger i {
    color: var(--gg-danger);
}
.toast-container .toast .toast-warning i {
    color: var(--gg-warning);
}
.toast-container .toast .toast-info i {
    color: var(--gg-primary);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.bg-surface-2 {
    background-color: var(--gg-surface-2) !important;
}

.bg-primary-subtle {
    background-color: var(--gg-primary-subtle) !important;
}
.bg-success-subtle {
    background-color: var(--gg-success-subtle) !important;
}
.bg-danger-subtle {
    background-color: var(--gg-danger-subtle) !important;
}
.bg-warning-subtle {
    background-color: var(--gg-warning-subtle) !important;
}
.bg-info-subtle {
    background-color: var(--gg-info-subtle) !important;
}
.bg-secondary-subtle {
    background-color: var(--gg-surface-2) !important;
}

.text-primary {
    color: var(--gg-primary) !important;
}
.text-success {
    color: var(--gg-success) !important;
}
.text-danger {
    color: var(--gg-danger) !important;
}
.text-warning {
    color: var(--gg-warning) !important;
}
.text-info {
    color: var(--gg-info) !important;
}
.text-secondary {
    color: var(--gg-text-secondary) !important;
}

.border {
    border-color: var(--gg-border) !important;
}

/* ============================================================
   RESPONSIVE (overrides and adjustments)
   ============================================================ */
@media (max-width: 1199px) {
    .main-content {
        padding: 1.25rem 1.5rem 1rem;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 290px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 290px;
    }

    .sidebar.collapsed.open {
        transform: translateX(0);
        width: 290px;
    }

    .sidebar.collapsed .brand-text {
        display: flex;
    }

    .sidebar.collapsed .brand-logo {
        height: 95px;
    }

    .sidebar.collapsed .sidebar-brand {
        justify-content: center;
        gap: 8px;
        padding-bottom: 1.75rem;
        margin-bottom: 1.75rem;
    }

    .sidebar.collapsed .sidebar-nav a {
        justify-content: flex-start;
        padding: 0.7rem 1rem;
        gap: 14px;
    }

    .sidebar.collapsed .sidebar-nav a i {
        font-size: 1.2rem;
        width: 1.6rem;
    }

    .sidebar.collapsed .sidebar-nav a span {
        display: inline;
    }

    .sidebar.collapsed .sidebar-nav a:hover::after {
        display: none;
    }

    .sidebar.collapsed .sidebar-footer .version,
    .sidebar.collapsed .sidebar-footer .copyright {
        display: flex;
    }

    .sidebar.collapsed .coming-badge {
        display: inline-block;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem 1rem 0.75rem;
    }

    .sidebar-toggle {
        display: flex;
    }

    .header-brand {
        display: flex;
    }

    .page-title {
        display: none;
    }

    /* Dimmed backdrop behind the off-canvas sidebar when open.
       :has() lets this stay pure-CSS with no JS/HTML changes;
       the existing document click-listener already closes the
       sidebar on any outside click, including this backdrop. */
    body:has(.sidebar.open)::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(6, 10, 20, 0.55);
        z-index: 1025;
        animation: fadeInBackdrop 0.2s ease;
    }

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

    .header-right .search-wrapper input {
        width: 150px;
    }

    .header-right .form-select {
        min-width: 100px;
    }

    .quick-actions {
        gap: 0.4rem;
    }

    .quick-actions .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.6rem;
    }

    .refresh-control {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .header-left {
        justify-content: space-between;
        width: 100%;
    }

    .header-right {
        width: 100%;
        justify-content: stretch;
        gap: 0.4rem;
    }

    .header-right .search-wrapper {
        flex: 1;
        min-width: 100%;
    }

    .header-right .search-wrapper input {
        width: 100%;
    }

    .header-right .form-select {
        flex: 1;
        min-width: 0;
        font-size: 0.7rem;
        padding: 0.25rem 1.4rem 0.25rem 0.4rem;
    }

    .header-right .btn-dark-mode {
        font-size: 1rem;
        padding: 0.15rem 0.3rem;
    }

    .header-time {
        font-size: 0.7rem;
    }

    .user-avatar {
        font-size: 1.3rem;
    }

    .table .action-btns .btn {
        font-size: 0.6rem;
        padding: 0.15rem 0.35rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .critical-item {
        flex-wrap: wrap;
        gap: 4px;
    }

    .critical-item .critical-time {
        margin-left: 0;
        width: 100%;
    }

    .critical-badge {
        margin-left: 0;
        width: 100%;
    }

    .quick-actions .btn {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    .app-footer {
        font-size: 0.65rem;
        gap: 0.3rem;
    }

    .page-title {
        font-size: 1rem;
    }

    .brand-logo {
        height: 96px;
    }

    /* ========================================================
       WEBSITE LIST -> PREMIUM CARDS (no squeezed table, ever)
       ======================================================== */
    .table-responsive {
        overflow-x: visible;
    }

    #websiteTable,
    #websiteTable tbody {
        display: block;
        width: 100%;
    }

    #websiteTable thead {
        display: none;
    }

    #websiteTable tbody tr {
        display: flex;
        flex-direction: column;
        position: relative;
        background: var(--gg-surface);
        border: 1px solid var(--gg-border);
        border-radius: var(--gg-radius);
        margin: 0 0.75rem 0.75rem;
        padding: 1rem;
        box-shadow: var(--gg-shadow);
    }

    #websiteTable tbody tr:last-child {
        margin-bottom: 0.25rem;
    }

    #websiteTable tbody tr:hover {
        background: var(--gg-surface);
    }

    #websiteTable tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.45rem 0;
        border-bottom: 1px dashed var(--gg-border);
        text-align: right;
    }

    #websiteTable tbody td:last-child {
        border-bottom: none;
    }

    #websiteTable tbody td::before {
        font-weight: 600;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--gg-text-muted);
        flex-shrink: 0;
    }

    #websiteTable tbody td:nth-child(3)::before { content: 'Category'; }
    #websiteTable tbody td:nth-child(4)::before { content: 'Type'; }
    #websiteTable tbody td:nth-child(5)::before { content: 'Status'; }
    #websiteTable tbody td:nth-child(6)::before { content: 'Last Checked'; }

    /* Pin -> small floating icon, top-right of the card */
    #websiteTable tbody td:nth-child(1) {
        position: absolute;
        top: 0.85rem;
        right: 0.85rem;
        border-bottom: none;
        padding: 0;
        width: auto;
    }

    /* Website name + URL -> full-width card header */
    #websiteTable tbody td:nth-child(2) {
        display: block;
        order: -1;
        padding: 0 2.25rem 0.75rem 0;
        margin-bottom: 0.4rem;
        border-bottom: 1px solid var(--gg-border);
    }

    #websiteTable tbody td:nth-child(2) .site-url {
        max-width: 100%;
        white-space: normal;
        word-break: break-all;
    }

    /* Actions -> full-width footer row, roomy 44px touch targets */
    #websiteTable tbody td:nth-child(7) {
        justify-content: center;
        padding-top: 0.85rem;
        border-bottom: none;
    }

    #websiteTable tbody .action-btns {
        justify-content: center;
        flex-wrap: wrap;
        width: 100%;
        gap: 0.5rem;
    }

    #websiteTable tbody .action-btns .btn {
        flex: 1;
        min-width: 44px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .table-container {
        padding: 0.5rem 0;
    }

    #websiteTable tbody tr {
        padding: 0.85rem;
    }

    #websiteTable tbody td {
        font-size: 0.8rem;
    }

    #websiteTable tbody .action-btns .btn {
        min-width: 40px;
        flex-basis: 30%;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
        padding: 0 0.75rem 0.5rem 0.75rem;
    }

    .table-title {
        font-size: 0.9rem;
    }

    .site-count {
        align-self: flex-start;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal .modal-dialog {
        margin: 0.5rem;
    }

    .quick-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-actions .btn {
        justify-content: center;
    }

    .refresh-control {
        justify-content: center;
        margin-top: 0.3rem;
    }

    .critical-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .critical-badge {
        width: auto;
    }

    .app-footer {
        flex-direction: column;
        gap: 0.2rem;
    }

    .app-footer .footer-divider {
        display: none;
    }

    .sidebar {
        padding: 1.25rem 1rem;
    }

    .brand-logo {
        height: 76px;
    }

    .header-logo {
        height: 28px;
    }

    .brand-name {
        font-size: 1rem;
    }

    .brand-subtitle {
        font-size: 0.6rem;
    }
}

@media (max-width: 360px) {
    .header-right {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }

    .header-right .search-wrapper,
    .header-right .header-time,
    .header-right .btn-dark-mode,
    .header-right .user-avatar {
        grid-column: 1 / -1;
    }

    .header-right .search-wrapper {
        order: -1;
    }

    .header-right .form-select {
        font-size: 0.72rem;
    }

    .header-brand-name {
        font-size: 0.95rem;
    }

    #websiteTable tbody .action-btns .btn {
        flex-basis: 22%;
        min-width: 38px;
    }

    .stat-card {
        padding: 0.85rem 1rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }
}