/**
 * Longevity ToolHub - Modular Bento Design System (Executive Full-Screen Edition)
 * 100% Full-Viewport Fluid Percentage Architecture
 * Sharp Square Modular Geometry • Comprehensive Color Tone System • Ultra-Light Performance
 */

/* ==========================================================================
   1. CSS RESET & GLOBAL BASE
   ========================================================================== */

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

:root {
    --fluid-px: clamp(0.75rem, 2.2vw, 2.75rem);
    --radius-sharp: 0px;
    --radius-subtle: 2px;
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Default Theme Variables: Obsidian Slate (Dark Master) */
    --bg-main: #0b0d14;
    --bg-surface: #121520;
    --bg-surface-elevated: #181c2b;
    --bg-subtle: #191e2e;
    --bg-hover: #1e2437;

    --border: #242a3e;
    --border-hover: #455075;
    --border-focus: #60a5fa;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #7e8b9f;

    --accent-main: #60a5fa;
    --accent-glow: rgba(96, 165, 250, 0.18);
    --accent-surface: rgba(96, 165, 250, 0.1);

    --status-online: #10b981;
    --status-offline: #f59e0b;
    --status-checking: #64748b;

    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.5);
    --shadow-modal: 0 16px 40px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   2. BỘ COLOR TONE PHONG PHÚ (COMPREHENSIVE COLOR TONES)
   7 Dark Tones & 4 Light Tones
   ========================================================================== */

/* --- DARK TONES --- */

/* 1. Obsidian Slate (Default) */
[data-tone="obsidian"], [data-theme="dark"]:not([data-tone]) {
    --bg-main: #0a0c12;
    --bg-surface: #11141c;
    --bg-surface-elevated: #171b26;
    --bg-subtle: #191e2b;
    --bg-hover: #1e2434;
    --border: #232838;
    --border-hover: #4e5772;
    --border-focus: #60a5fa;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #838fa3;
    --accent-main: #60a5fa;
    --accent-glow: rgba(96, 165, 250, 0.18);
    --accent-surface: rgba(96, 165, 250, 0.08);
}

/* 2. Cyber Emerald (High-tech Mint / Matrix Green) */
[data-tone="emerald"] {
    --bg-main: #06110d;
    --bg-surface: #0a1b14;
    --bg-surface-elevated: #10261d;
    --bg-subtle: #122b21;
    --bg-hover: #17372a;
    --border: #193f2f;
    --border-hover: #10b981;
    --border-focus: #34d399;
    --text-primary: #f0fdf4;
    --text-secondary: #bbf7d0;
    --text-muted: #6ee7b7;
    --accent-main: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.22);
    --accent-surface: rgba(16, 185, 129, 0.1);
}

/* 3. Cobalt Space (Deep Electric Blue) */
[data-tone="cobalt"] {
    --bg-main: #050b17;
    --bg-surface: #0b1528;
    --bg-surface-elevated: #11203d;
    --bg-subtle: #132445;
    --bg-hover: #182e56;
    --border: #1c3563;
    --border-hover: #38bdf8;
    --border-focus: #60a5fa;
    --text-primary: #f0f9ff;
    --text-secondary: #bae6fd;
    --text-muted: #7dd3fc;
    --accent-main: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.22);
    --accent-surface: rgba(56, 189, 248, 0.1);
}

/* 4. Industrial Amber (Forge Matte Carbon & Gold Amber) */
[data-tone="amber"] {
    --bg-main: #120e09;
    --bg-surface: #1b150d;
    --bg-surface-elevated: #261f14;
    --bg-subtle: #2b2316;
    --bg-hover: #372d1c;
    --border: #3f321d;
    --border-hover: #f59e0b;
    --border-focus: #fbbf24;
    --text-primary: #fffbeb;
    --text-secondary: #fde68a;
    --text-muted: #d97706;
    --accent-main: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.22);
    --accent-surface: rgba(245, 158, 11, 0.1);
}

/* 5. Crimson Cyber (Stealth Carbon & Fiery Ruby) */
[data-tone="crimson"] {
    --bg-main: #12070a;
    --bg-surface: #1c0c11;
    --bg-surface-elevated: #281219;
    --bg-subtle: #2e151d;
    --bg-hover: #3b1a26;
    --border: #441a27;
    --border-hover: #f43f5e;
    --border-focus: #fb7185;
    --text-primary: #fff1f2;
    --text-secondary: #fecdd3;
    --text-muted: #fb7185;
    --accent-main: #f43f5e;
    --accent-glow: rgba(244, 63, 94, 0.22);
    --accent-surface: rgba(244, 63, 94, 0.1);
}

/* 6. Velvet Amethyst (Deep Void & Electric Purple) */
[data-tone="amethyst"] {
    --bg-main: #0e0817;
    --bg-surface: #160d24;
    --bg-surface-elevated: #201335;
    --bg-subtle: #24163b;
    --bg-hover: #2f1d4d;
    --border: #38215c;
    --border-hover: #a855f7;
    --border-focus: #c084fc;
    --text-primary: #faf5ff;
    --text-secondary: #e9d5ff;
    --text-muted: #c084fc;
    --accent-main: #a855f7;
    --accent-glow: rgba(168, 85, 247, 0.22);
    --accent-surface: rgba(168, 85, 247, 0.1);
}

/* 7. OLED Monochrome (Pure Black & Crisp Silver) */
[data-tone="matrix"] {
    --bg-main: #000000;
    --bg-surface: #0c0c0c;
    --bg-surface-elevated: #151515;
    --bg-subtle: #1a1a1a;
    --bg-hover: #242424;
    --border: #282828;
    --border-hover: #ffffff;
    --border-focus: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #e5e5e5;
    --text-muted: #8c8c8c;
    --accent-main: #ffffff;
    --accent-glow: rgba(255, 255, 255, 0.25);
    --accent-surface: rgba(255, 255, 255, 0.1);
}

/* --- LIGHT TONES --- */

/* 8. Pure Minimalist Light */
[data-tone="pure-light"], [data-theme="light"]:not([data-tone]) {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --bg-subtle: #f1f5f9;
    --bg-hover: #e2e8f0;
    --border: #cbd5e1;
    --border-hover: #0f172a;
    --border-focus: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent-main: #0f172a;
    --accent-glow: rgba(15, 23, 42, 0.15);
    --accent-surface: rgba(15, 23, 42, 0.06);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.07);
    --shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.12);
    --shadow-modal: 0 16px 36px rgba(0, 0, 0, 0.18);
}

/* 9. Nordic Ice (Arctic Mist) */
[data-tone="nordic"] {
    --bg-main: #f0fdfa;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #e6fffa;
    --bg-subtle: #e6fffa;
    --bg-hover: #ccfbf1;
    --border: #99f6e4;
    --border-hover: #0d9488;
    --border-focus: #0d9488;
    --text-primary: #134e4a;
    --text-secondary: #115e59;
    --text-muted: #0f766e;
    --accent-main: #0d9488;
    --accent-glow: rgba(13, 148, 136, 0.18);
    --accent-surface: rgba(13, 148, 136, 0.08);
    --shadow-card: 0 1px 3px rgba(13, 148, 136, 0.08);
    --shadow-hover: 0 4px 14px rgba(13, 148, 136, 0.15);
}

/* 10. Warm Sand (Linen / Cream Espresso) */
[data-tone="sand"] {
    --bg-main: #faf7f2;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f4efe6;
    --bg-subtle: #f4efe6;
    --bg-hover: #ede4d6;
    --border: #dcd0bf;
    --border-hover: #78350f;
    --border-focus: #92400e;
    --text-primary: #451a03;
    --text-secondary: #78350f;
    --text-muted: #92400e;
    --accent-main: #b45309;
    --accent-glow: rgba(180, 83, 9, 0.18);
    --accent-surface: rgba(180, 83, 9, 0.08);
    --shadow-card: 0 1px 3px rgba(69, 26, 3, 0.07);
    --shadow-hover: 0 4px 14px rgba(69, 26, 3, 0.14);
}

/* 11. Matcha Sage (Organic Minimalist) */
[data-tone="sage"] {
    --bg-main: #f3f6f3;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #e6ede6;
    --bg-subtle: #e6ede6;
    --bg-hover: #d7e4d7;
    --border: #c4d7c4;
    --border-hover: #166534;
    --border-focus: #15803d;
    --text-primary: #14532d;
    --text-secondary: #166534;
    --text-muted: #15803d;
    --accent-main: #15803d;
    --accent-glow: rgba(21, 128, 61, 0.18);
    --accent-surface: rgba(21, 128, 61, 0.08);
    --shadow-card: 0 1px 3px rgba(20, 83, 45, 0.07);
    --shadow-hover: 0 4px 14px rgba(20, 83, 45, 0.14);
}

/* ==========================================================================
   3. BASE LAYOUT & TYPOGRAPHY
   ========================================================================== */

html {
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
}

body {
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

a {
    color: inherit;
    text-decoration: none;
}

.hidden {
    display: none !important;
}

.svg-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    flex-shrink: 0;
}

/* ==========================================================================
   4. APP HEADER (FULL-WIDTH 100% FLUID COMMAND BAR)
   ========================================================================== */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-container {
    width: 100%;
    padding: 0 var(--fluid-px);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Brand Link */
.brand-block {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand-logo-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sharp);
    background: var(--accent-main);
    color: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-hover);
}

.brand-logo-icon .svg-icon {
    width: 17px;
    height: 17px;
    stroke-width: 2.2;
}

.brand-title {
    white-space: nowrap;
}

/* Center Search Box */
.header-search {
    flex: 1;
    max-width: clamp(240px, 34vw, 620px);
    position: relative;
}

.search-box-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    padding: 0 0.85rem;
    height: 36px;
    transition: border-color 0.15s, background-color 0.15s;
}

.search-box-wrapper:focus-within {
    border-color: var(--border-focus);
    background: var(--bg-surface);
    box-shadow: 0 0 0 1px var(--border-focus);
}

.search-icon {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    width: 100%;
}

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

.kbd-hint {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    padding: 2px 5px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    color: var(--text-muted);
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
}

.clear-search-btn {
    color: var(--text-muted);
    padding: 4px;
    font-size: 0.8rem;
    line-height: 1;
}

.clear-search-btn:hover {
    color: var(--text-primary);
}

/* Header Controls & Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Lang Switch */
.lang-switch {
    display: flex;
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    padding: 2px;
    gap: 2px;
}

.lang-btn {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 7px;
    border-radius: var(--radius-sharp);
    color: var(--text-muted);
    transition: all 0.12s ease;
}

.lang-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.lang-sep {
    display: none;
}

/* View Switcher */
.view-switch {
    display: flex;
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    padding: 2px;
    gap: 2px;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border-radius: var(--radius-sharp);
    color: var(--text-muted);
    transition: all 0.12s;
}

.view-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.view-btn .svg-icon {
    width: 14px;
    height: 14px;
}

/* Color Tone Trigger Button */
.tone-picker-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 32px;
    padding: 0 0.75rem;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.tone-picker-trigger-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-subtle);
}

.tone-dot-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-main);
    box-shadow: 0 0 6px var(--accent-main);
    flex-shrink: 0;
}

.tone-btn-label {
    white-space: nowrap;
}

/* Admin Entry Button */
.admin-entry-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 32px;
    padding: 0 0.75rem;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.admin-entry-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.admin-entry-btn .svg-icon {
    width: 13px;
    height: 13px;
}

/* ==========================================================================
   5. ADMIN BAR (SUB-HEADER)
   ========================================================================== */

.admin-bar {
    width: 100%;
    background: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0.45rem 0;
}

.admin-bar-inner {
    width: 100%;
    padding: 0 var(--fluid-px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-welcome {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.825rem;
    font-weight: 600;
}

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

/* ==========================================================================
   6. MAIN CANVAS & DEPARTMENT TABS (FULL-WIDTH 100%)
   ========================================================================== */

.main-canvas {
    flex: 1;
    width: 100%;
    padding: 1.25rem 0 2.5rem;
    display: flex;
    flex-direction: column;
}

.content-container {
    width: 100%;
    padding: 0 var(--fluid-px);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Department Navigation Tabs (Sharp Modular Blocks) */
.dept-tabs-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.65rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
}

.dept-tabs-nav::-webkit-scrollbar {
    display: none;
}

.dept-tab-btn, .cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.8rem;
    border-radius: var(--radius-sharp);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: all 0.12s ease;
    user-select: none;
}

.dept-tab-btn:hover, .cat-pill:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

.dept-tab-btn.active, .cat-pill.active {
    background: var(--accent-main);
    color: var(--bg-surface);
    border-color: var(--accent-main);
    font-weight: 600;
}

.dept-tab-btn .count-badge, .cat-pill .count-badge {
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: var(--radius-sharp);
    background: rgba(125, 125, 125, 0.2);
    line-height: 1.2;
}

.dept-tab-btn.active .count-badge, .cat-pill.active .count-badge {
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
}

/* ==========================================================================
   7. MODULAR BENTO GRID (BALANCED FLUID PERCENTAGE GRID)
   Scales seamlessly across all viewports without breaking
   ========================================================================== */

.links-view-grid {
    display: grid;
    width: 100%;
    gap: clamp(0.5rem, 0.8vw, 0.9rem);
    /* Default standard 1080p desktop: 5 columns (20% each) */
    grid-template-columns: repeat(5, 1fr);
    align-content: start;
}

/* 4K & Ultrawide Monitors ( >= 2200px ): 7 columns (~14.28% each) */
@media (min-width: 2200px) {
    .links-view-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}

/* Large Displays ( 1800px - 2199px ): 6 columns (~16.66% each) */
@media (min-width: 1800px) and (max-width: 2199px) {
    .links-view-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Standard Laptops & 1080p Displays ( 1280px - 1799px ): 5 columns (20% each) */
@media (min-width: 1280px) and (max-width: 1799px) {
    .links-view-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Compact Laptops & Large Tablets ( 960px - 1279px ): 4 columns (25% each) */
@media (min-width: 960px) and (max-width: 1279px) {
    .links-view-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablets in Portrait ( 680px - 959px ): 3 columns (33.33% each) */
@media (min-width: 680px) and (max-width: 959px) {
    .links-view-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Smartphones & Phablets ( 460px - 679px ): 2 columns (50% each) */
@media (min-width: 460px) and (max-width: 679px) {
    .links-view-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small Smartphones ( < 460px ): 1 column (100% full width) */
@media (max-width: 459px) {
    .links-view-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   8. MODULAR TOOL CARD (SHARP BENTO BLOCKS)
   Pure Geometric Square / Rectangle Modular Card
   ========================================================================== */

.tool-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(0.85rem, 1vw, 1.15rem);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    cursor: pointer;
    position: relative;
    user-select: none;
    outline: none;
    min-height: 84px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.tool-card:hover {
    border-color: var(--accent-main);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: var(--bg-surface-elevated);
}

.tool-card:active {
    transform: scale(0.985);
}

.tool-card:focus-visible {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--border-focus);
}

/* Card Body Layout */
.tool-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* With Thumbnail Image Header */
.tool-card-top-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
}

.tool-thumbnail-box {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: var(--radius-sharp);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.tool-thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tool-info-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tool-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.tool-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex: 1;
}

.tool-title {
    font-size: clamp(0.92rem, 0.95vw, 1.02rem);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-arrow {
    font-size: 0.92rem;
    color: var(--text-muted);
    opacity: 0.45;
    transition: opacity 0.15s, transform 0.15s, color 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.tool-card:hover .tool-arrow {
    opacity: 1;
    transform: translate(2px, -2px);
    color: var(--accent-main);
}

.tool-meta {
    font-size: clamp(0.72rem, 0.76vw, 0.82rem);
    color: var(--text-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Status Dot (Local server probe) */
.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--status-checking);
    flex-shrink: 0;
}

.status-dot.online {
    background-color: var(--status-online);
    box-shadow: 0 0 6px var(--status-online);
}

.status-dot.offline {
    background-color: var(--status-offline);
}

.status-dot.checking {
    background-color: var(--status-checking);
}

/* ==========================================================================
   9. COLOR ACCENT VARIANTS FOR MODULES (NÚT CÓ THỂ CHỌN MÀU NHẤN)
   ========================================================================== */

.tool-card.accent-emerald {
    border-left: 3px solid #10b981;
}
.tool-card.accent-emerald:hover {
    border-color: #10b981;
}
.tool-card.accent-emerald .tool-arrow {
    color: #10b981;
}

.tool-card.accent-blue {
    border-left: 3px solid #3b82f6;
}
.tool-card.accent-blue:hover {
    border-color: #3b82f6;
}
.tool-card.accent-blue .tool-arrow {
    color: #3b82f6;
}

.tool-card.accent-amber {
    border-left: 3px solid #f59e0b;
}
.tool-card.accent-amber:hover {
    border-color: #f59e0b;
}
.tool-card.accent-amber .tool-arrow {
    color: #f59e0b;
}

.tool-card.accent-rose {
    border-left: 3px solid #f43f5e;
}
.tool-card.accent-rose:hover {
    border-color: #f43f5e;
}
.tool-card.accent-rose .tool-arrow {
    color: #f43f5e;
}

.tool-card.accent-violet {
    border-left: 3px solid #a855f7;
}
.tool-card.accent-violet:hover {
    border-color: #a855f7;
}
.tool-card.accent-violet .tool-arrow {
    color: #a855f7;
}

.tool-card.accent-cyan {
    border-left: 3px solid #06b6d4;
}
.tool-card.accent-cyan:hover {
    border-color: #06b6d4;
}
.tool-card.accent-cyan .tool-arrow {
    color: #06b6d4;
}

/* ==========================================================================
   10. LIST / DETAILED VIEW (FULL-WIDTH FLUID)
   ========================================================================== */

.links-view-detailed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.tool-card.tool-card-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    padding: 0.75rem 1.15rem;
}

.tool-card.tool-card-row .tool-body {
    flex: 1;
    min-width: 0;
}

.tool-row-end {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1rem;
    flex-shrink: 0;
}

.tool-desc-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

.tool-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   11. ADMIN MINI BUTTONS ON CARDS
   ========================================================================== */

.admin-card-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--border);
    justify-content: flex-end;
}

.tool-card-row .admin-card-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.admin-mini-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    transition: all 0.12s ease;
}

.admin-mini-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

.admin-mini-btn.btn-del:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.admin-mini-btn .svg-icon {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   12. BUTTONS & CONTROLS DESIGN (SHARP SQUARE)
   ========================================================================== */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sharp);
    font-weight: 600;
    font-size: 0.85rem;
    background: var(--accent-main);
    color: var(--bg-surface);
    border: 1px solid var(--accent-main);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sharp);
    font-weight: 600;
    font-size: 0.85rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-outline:hover {
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sharp);
    font-weight: 600;
    font-size: 0.85rem;
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-secondary:hover {
    border-color: var(--border-hover);
}

.btn-danger-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sharp);
    font-weight: 600;
    font-size: 0.85rem;
    background: transparent;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
    transition: all 0.15s ease;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    height: 30px;
}

/* ==========================================================================
   13. MODALS (DIALOGS) & BACKDROP (SHARP SQUARE GEOMETRY)
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.modal-dialog {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 840px; }

.modal-header {
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg-surface-elevated);
}

.modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-header-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sharp);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--accent-main);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.modal-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.modal-close-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all 0.12s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

.modal-body {
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    background: var(--bg-surface-elevated);
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

@media (max-width: 540px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.field-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.form-control:focus {
    border-color: var(--border-focus);
    background: var(--bg-surface);
    box-shadow: 0 0 0 1px var(--border-focus);
}

.alert-error {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sharp);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    font-size: 0.825rem;
    font-weight: 500;
}

/* ==========================================================================
   14. IMAGE UPLOAD & CANVAS COMPRESSION COMPONENT (SIÊU NHẸ)
   ========================================================================== */

.image-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
}

.image-preview-box {
    width: 60px;
    height: 60px;
    min-width: 60px;
    border-radius: var(--radius-sharp);
    border: 1px dashed var(--border-hover);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.image-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-align: center;
    padding: 4px;
}

.image-preview-empty .svg-icon {
    width: 22px;
    height: 22px;
    opacity: 0.6;
}

.image-preview-loaded {
    width: 100%;
    height: 100%;
    position: relative;
}

.image-preview-loaded img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.image-upload-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.btn-file-upload {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    width: fit-content;
}

.btn-file-upload:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.hidden-file-input {
    display: none;
}

.badge-optimized {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--radius-sharp);
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10b981;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.btn-remove-image {
    color: #ef4444;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 6px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sharp);
    background: rgba(239, 68, 68, 0.08);
    transition: all 0.12s;
    cursor: pointer;
}

.btn-remove-image:hover {
    background: rgba(239, 68, 68, 0.2);
}

.image-info-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

/* ==========================================================================
   15. COLOR ACCENT PICKER IN MODAL
   ========================================================================== */

.color-accent-picker {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.accent-option {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 500;
    transition: all 0.12s;
}

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

.accent-option.active {
    border-color: var(--text-primary);
    background: var(--bg-hover);
    font-weight: 600;
}

.accent-swatch {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-sharp);
    display: inline-block;
}

.swatch-default { background: var(--border-hover); }
.swatch-emerald { background: #10b981; }
.swatch-blue    { background: #3b82f6; }
.swatch-amber   { background: #f59e0b; }
.swatch-rose    { background: #f43f5e; }
.swatch-violet  { background: #a855f7; }
.swatch-cyan    { background: #06b6d4; }

/* ==========================================================================
   16. BỘ COLOR TONE PICKER MODAL (CARDS & PREVIEWS)
   ========================================================================== */

.tone-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.tone-section-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: var(--radius-sharp);
    border: 1px solid #334155;
}

.tone-section-badge.light {
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.tone-section-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.tone-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.6rem;
}

.tone-card-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sharp);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    user-select: none;
}

.tone-card-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.tone-card-item.active {
    border-color: var(--accent-main);
    background: var(--bg-surface-elevated);
    box-shadow: 0 0 0 1px var(--accent-main);
}

.tone-mini-palette {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sharp);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.tone-mini-accent-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.tone-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tone-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tone-card-tag {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.tone-active-check {
    position: absolute;
    right: 8px;
    width: 14px;
    height: 14px;
    color: var(--accent-main);
    display: none;
}

.tone-card-item.active .tone-active-check {
    display: block;
}

/* ==========================================================================
   17. DEPT CHECKBOX SELECTOR IN EDITOR MODAL
   ========================================================================== */

.dept-checkbox-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-height: 140px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
}

.dept-chip-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sharp);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.12s;
    user-select: none;
}

.dept-chip-label:hover {
    border-color: var(--border-hover);
}

.dept-chip-label.active {
    background: var(--accent-main);
    color: var(--bg-surface);
    border-color: var(--accent-main);
    font-weight: 600;
}

.dept-chip-label input {
    display: none;
}

.group-select-shortcuts {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
}

.btn-link-action {
    color: var(--accent-main);
    font-weight: 600;
}

/* Type Selector Cards */
.type-selector-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.type-card {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all 0.15s;
}

.type-card.active {
    border-color: var(--accent-main);
    background: var(--bg-hover);
}

.hidden-radio {
    display: none;
}

.type-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: var(--radius-sharp);
}

.badge-web { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-local { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.type-desc {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==========================================================================
   18. TOAST NOTIFICATIONS & FOOTER
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius-sharp);
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-modal);
    font-size: 0.825rem;
    font-weight: 600;
    pointer-events: auto;
    animation: toastFadeIn 0.2s ease-out;
}

@keyframes toastFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast-success { border-left: 3px solid #10b981; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-info { border-left: 3px solid var(--accent-main); }

.app-footer {
    width: 100%;
    padding: 0.75rem var(--fluid-px);
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.empty-state {
    padding: 4rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.empty-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Skeleton Card */
.skeleton-card {
    height: 84px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sharp);
    animation: skeletonPulse 1.4s ease-in-out infinite;
}

@keyframes skeletonPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
