/* Font Import */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

/* --- Custom Theme Variables --- */
:root {
    --font-family-main: 'Poppins', sans-serif;
    --primary-color: #1abc9c;
    --primary-hover-color: #16a085;
    --secondary-color: #9b59b6;
    --accent-color: #f1c40f;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #34495e;
    --text-muted-color: #7f8c8d;
    --border-color: #dfe6e9;
    --input-bg: #ffffff;
    --input-border: #bdc3c7;
    --input-placeholder-color: #95a5a6;
    --input-clear-btn-color: var(--text-muted-color);
    --input-clear-btn-hover-color: var(--text-color);
    --shadow-color: rgba(52, 73, 94, 0.15);
    --shadow-hover-color: rgba(52, 73, 94, 0.25);
    --tag-bg: #dfe6e9;
    --tag-color: #34495e;
    --tag-active-bg: var(--primary-color);
    --tag-active-color: #ffffff;
    --error-fallback-bg: #f2f2f2;
    --error-fallback-icon-color: #bdc3c7;
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 16px;
    --transition-speed: 0.25s;
    --shadow-sm: 0 2px 4px var(--shadow-color);
    --shadow-md: 0 4px 10px var(--shadow-color);
    --shadow-lg: 0 8px 20px var(--shadow-hover-color);
    --header-gradient: linear-gradient(135deg, #bdc3c7, var(--primary-color));
    --fab-bg-color: var(--text-color);
    --fab-icon-color: var(--card-bg);
    --fab-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    --fab-hover-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    --tooltip-bg: var(--text-color);
    --tooltip-color: var(--bg-color);
    --scrollbar-thumb-color: var(--primary-color);
    --scrollbar-track-color: transparent;
    --tag-toggle-text-color: rgba(255, 255, 255, 0.9);
    --tag-toggle-border-color: rgba(255, 255, 255, 0.2);
    --tag-toggle-bg-color: rgba(255, 255, 255, 0.1);
    --tag-toggle-bg-hover-color: rgba(255, 255, 255, 0.2);
    --tag-filter-button-color: rgba(255, 255, 255, 0.9);
    --tag-filter-button-bg-color: rgba(255, 255, 255, 0.15);
    --tag-filter-button-border-color: rgba(255, 255, 255, 0.2);
    --tag-filter-button-hover-bg-color: rgba(255, 255, 255, 0.3);
    --tag-filter-button-active-color: #333;
    --tag-filter-button-active-bg-color: var(--accent-color);
}

[data-theme="dark"] {
    --primary-color: #1abc9c;
    --primary-hover-color: #2ecc71;
    --secondary-color: #8e44ad;
    --accent-color: #f39c12;
    --bg-color: #2c3e50;
    --card-bg: #34495e;
    --text-color: #ecf0f1; /* Light text */
    --text-muted-color: #95a5a6;
    --border-color: #4a6179;
    --input-bg: #4a6179;
    --input-border: #5b7289;
    --input-placeholder-color: rgba(236, 240, 241, 0.6);
    --input-clear-btn-color: rgba(236, 240, 241, 0.7); /* Brighter color for dark mode */
    --input-clear-btn-hover-color: #ffffff; /* White on hover */
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover-color: rgba(0, 0, 0, 0.5);
    --tag-bg: #4a6179;
    --tag-color: #ecf0f1;
    --tag-active-bg: var(--primary-color);
    --tag-active-color: #ffffff;
    --error-fallback-bg: #4a6179;
    --error-fallback-icon-color: #7f8c8d;
    --header-gradient: linear-gradient(135deg, var(--card-bg), var(--secondary-color));
    --fab-bg-color: #e0e5e8; /* Light FAB */
    --fab-icon-color: #34495e; /* Dark Icon */
    --fab-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    --fab-hover-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    --tooltip-bg: var(--text-color); /* Keep tooltip darkish */
    --tooltip-color: var(--bg-color); /* With light text */
    --scrollbar-thumb-color: var(--primary-color);
    --scrollbar-track-color: transparent;
    --tag-toggle-text-color: rgba(236, 240, 241, 0.9);
    --tag-toggle-border-color: rgba(236, 240, 241, 0.2);
    --tag-toggle-bg-color: rgba(236, 240, 241, 0.1);
    --tag-toggle-bg-hover-color: rgba(236, 240, 241, 0.2);
    --tag-filter-button-color: rgba(236, 240, 241, 0.9);
    --tag-filter-button-bg-color: rgba(236, 240, 241, 0.15);
    --tag-filter-button-border-color: rgba(236, 240, 241, 0.2);
    --tag-filter-button-hover-bg-color: rgba(236, 240, 241, 0.3);
    --tag-filter-button-active-color: #333;
    --tag-filter-button-active-bg-color: var(--accent-color);
}

/* --- Base Styles --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    /* Smooth scrolling */
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    min-height: 100dvh; /* Use dynamic viewport height */
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.dashboard-header {
    background: var(--header-gradient);
    color: #fff; /* Header text is generally white regardless of theme */
    padding-top: 1rem;
    padding-bottom: 0.8rem;
    padding-left: calc(2rem + env(safe-area-inset-left));
    padding-right: calc(2rem + env(safe-area-inset-right));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    left: 0;
    right: 0;
    box-sizing: border-box;
    transition: background var(--transition-speed) ease;
}

.dashboard-header h1 {
    text-align: center;
    margin-bottom: 0.8rem;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: stretch; /* Align items including search container */
    justify-content: center;
    margin-bottom: 0.8rem;
}

/* Search Container */
.search-container {
    position: relative;
    display: flex; /* Use flex to align input and button */
    flex-grow: 1;
    max-width: 500px;
    align-items: center; /* Center button vertically */
}

/* Search Input adjustments */
.controls input[type="search"] {
    padding: 0.7rem 2.8rem 0.7rem 1rem; /* Increased right padding for clear button */
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    font-family: inherit;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease, border-color var(--transition-speed) ease, box-shadow 0.2s ease;
    min-width: 250px;
    flex-grow: 1; /* Allow input to grow */
    width: 100%; /* Take available space within container */
    /* Remove default search cancel button if browser adds one */
    appearance: none;
    -webkit-appearance: none;
}
/* Style for browser's built-in search cancel (might not be needed with custom button) */
.controls input[type="search"]::-webkit-search-cancel-button,
.controls input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none; /* Hide it */
}


.controls select {
    padding: 0.7rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    font-family: inherit;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease, border-color var(--transition-speed) ease, box-shadow 0.2s ease;
    flex-shrink: 0; /* Prevent select from shrinking too much */
}

.controls input[type="search"]::placeholder {
    color: var(--input-placeholder-color);
    opacity: 1;
    transition: color var(--transition-speed) ease;
}

.controls input[type="search"]:focus,
.controls select:focus {
     outline: none;
     border-color: var(--primary-color);
     box-shadow: 0 0 0 3px rgba(26, 188, 156, 0.3);
}

/* Search Clear Button */
.search-clear-btn {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--input-clear-btn-color); /* Use variable */
    cursor: pointer;
    font-size: 1.4rem; /* Slightly larger for easier tapping */
    line-height: 1;
    padding: 0 0.3rem;
    display: none; /* Hidden by default, shown by JS via container class */
    transition: color 0.2s ease, opacity 0.2s ease;
    z-index: 2;
}

.search-clear-btn:hover,
.search-clear-btn:focus {
    color: var(--input-clear-btn-hover-color); /* Use variable */
    outline: none;
}

/* Class added by JS to the container to show the button */
.search-container.show-clear .search-clear-btn {
    display: block;
}

/* --- Tag Filter Section --- */
.tags-toggle-btn {
    display: none; /* Shown by JS if tags exist */
    width: calc(100% - 4rem); /* Adjusted based on header padding */
    margin: 0 auto 0.8rem auto;
    padding: 0.4rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    background-color: var(--tag-toggle-bg-color);
    color: var(--tag-toggle-text-color);
    border: 1px solid var(--tag-toggle-border-color);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.tags-toggle-btn:hover {
    background-color: var(--tag-toggle-bg-hover-color);
}

.tags-toggle-btn:focus-visible {
     outline: 2px solid var(--accent-color);
     outline-offset: 2px;
}

.tags-toggle-btn .toggle-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transition: transform 0.3s ease-in-out;
    width: 0.7em; /* Adjust size */
    height: 0.7em;
    display: inline-block;
    border-style: solid;
    border-color: currentColor; /* Inherit button text color */
    border-width: 0 2px 2px 0;
    padding: 2.5px; /* Adjust padding for thickness */
    opacity: 0.8;
    transform: translateY(-60%) rotate(45deg);
}

.tags-toggle-btn[aria-expanded="true"] .toggle-icon {
    transform: translateY(-40%) rotate(-135deg);
}

.tag-filters {
    padding: 0;
    margin: 0 2rem; /* Match header padding */
    display: none; /* Hidden by default, shown by JS if tags exist */
}

.tags-inner-collapsible {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.35s ease-in-out,
                opacity 0.2s ease-in-out 0.1s, /* Delay opacity */
                visibility 0s linear 0.35s; /* Hide instantly when collapsed */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.4rem 0.2rem; /* Add padding for content */
}

.tags-inner-collapsible.expanded {
    max-height: 250px; /* Adjust max-height as needed */
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 1;
    visibility: visible;
    transition: max-height 0.35s ease-in-out,
                opacity 0.2s ease-in-out, /* Fade in */
                visibility 0s linear 0s; /* Become visible immediately */
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
}

.tags-inner-collapsible.expanded::-webkit-scrollbar {
    width: 6px;
}

.tags-inner-collapsible.expanded::-webkit-scrollbar-track {
    background: var(--scrollbar-track-color);
}

.tags-inner-collapsible.expanded::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb-color);
    border-radius: 3px;
    border: none;
}

.tags-inner-collapsible button {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    background-color: var(--tag-filter-button-bg-color);
    color: var(--tag-filter-button-color);
    border: 1px solid var(--tag-filter-button-border-color);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
    pointer-events: auto;
    touch-action: manipulation; /* Improve touch responsiveness */
}

.tags-inner-collapsible button:hover {
    background-color: var(--tag-filter-button-hover-bg-color);
    transform: translateY(-1px);
}

.tags-inner-collapsible button.active {
    background-color: var(--tag-filter-button-active-bg-color);
    color: var(--tag-filter-button-active-color);
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.tags-inner-collapsible button:active {
     transform: translateY(0px); /* Press down effect */
}

/* --- Main Content Area --- */
main {
    padding: 2rem;
    flex-grow: 1; /* Ensure main content takes available space */
    padding-bottom: calc(80px + env(safe-area-inset-bottom)); /* Space for FAB and footer */
}

/* Loading Indicator */
#loading-indicator {
    text-align: center;
    padding: 3rem;
    font-size: 1.1rem;
    color: var(--text-muted-color);
    display: flex; /* Use flex for alignment */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 200px; /* Ensure it takes some space */
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transition: border-color var(--transition-speed) ease;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No Results */
#no-results {
    text-align: center;
    padding: 3rem;
    font-size: 1.1rem;
    color: var(--text-muted-color);
    background-color: var(--card-bg);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    display: none; /* Hidden by default */
    margin: 1rem auto; /* Center it */
    max-width: 600px;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.8rem;
}

/* Service Tile */
.service-tile {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
    opacity: 0; /* Start hidden for animation */
    animation: fadeIn 0.5s ease-out forwards;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.service-tile:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.service-tile a {
    text-decoration: none;
    color: inherit; /* Inherit text color from parent */
    display: flex;
    flex-direction: column;
    height: 100%; /* Make link fill the tile */
    padding: 1.5rem;
    /* Prevent text selection on long press/drag for tooltip */
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Image Wrapper & Placeholder */
.service-image-wrapper {
    width: 90px;
    height: 90px;
    margin: 0 auto 1.5rem auto;
    border-radius: var(--border-radius-md);
    background-color: var(--bg-color); /* Use main bg color for contrast */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: background-color var(--transition-speed) ease;
    flex-shrink: 0; /* Prevent wrapper from shrinking */
}

.service-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Use contain to see whole logo */
    transition: transform 0.3s ease;
    pointer-events: none; /* Prevent image interfering with link interactions */
    /* Ensure transparent pixels are handled correctly */
    image-rendering: -webkit-optimize-contrast; /* Try to keep edges sharp */
    image-rendering: crisp-edges;
}
.service-tile:hover img {
    transform: scale(1.08);
}

/* Fallback Styling */
.service-tile img.error {
    content: ''; /* Required for background/mask to show */
    display: block;
    width: 60%; /* Make icon smaller than wrapper */
    height: 60%;
    background-color: var(--error-fallback-icon-color);
    /* Use an embedded SVG for better scaling and color control */
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16"><path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h13zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"/><path d="M4.502 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/><path d="M14.002 13a2 2 0 0 1-2-2h-10a2 2 0 0 1-2 2v-1a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v1z"/></svg>');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16"><path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h13zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"/><path d="M4.502 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/><path d="M14.002 13a2 2 0 0 1-2-2h-10a2 2 0 0 1-2 2v-1a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v1z"/></svg>');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    filter: none; /* Remove any filters */
    opacity: 0.8;
    transform: scale(1); /* Reset transform */
    font-size: 0; /* Hide any potential text content */
    line-height: 0;
    border: none;
    outline: none;
    color: transparent; /* Hide potential text color */
    object-fit: fill; /* Prevent stretching if it were an actual img element */
}
.service-tile img.error:hover {
     transform: none; /* Prevent hover scale on error icon */
}
.service-image-wrapper.error {
    background-color: var(--error-fallback-bg);
}

.service-tile h3 {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 0; /* Remove bottom margin */
    text-align: center;
    word-break: break-word; /* Prevent long titles overflowing */
    flex-grow: 1; /* Allow title to take remaining space */
    display: flex; /* Use flex to center text vertically */
    align-items: center; /* Vertical centering */
    justify-content: center; /* Horizontal centering */
    min-height: 40px; /* Ensure consistent height */
}

/* Fade-in Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Custom Tooltip --- */
.custom-tooltip {
    position: fixed; /* Use fixed to position relative to viewport */
    left: 0; /* Position updated by JS */
    top: 0;  /* Position updated by JS */
    z-index: 1050; /* High z-index */
    background-color: var(--tooltip-bg);
    color: var(--tooltip-color);
    padding: 0.5rem 0.8rem;
    border-radius: var(--border-radius-md);
    font-size: 0.85rem;
    line-height: 1.4;
    max-width: 250px;
    text-align: center;
    word-wrap: break-word; /* Wrap long descriptions */
    opacity: 0; /* Start hidden */
    visibility: hidden;
    pointer-events: none; /* Tooltip should not be interactive */
    transform: translateY(10px); /* Start slightly lower */
    transition: opacity 0.2s ease-in-out,
                visibility 0s linear 0.2s, /* Delay visibility change */
                transform 0.2s ease-in-out;
}

.custom-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0); /* Move to final position */
    transition: opacity 0.2s ease-in-out,
                visibility 0s linear 0s, /* Make visible immediately */
                transform 0.2s ease-in-out;
}

/* --- Floating Action Button (FAB) for Dark Mode --- */
#dark-mode-toggle {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    z-index: 1000;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background-color: var(--fab-bg-color);
    color: var(--fab-icon-color);
    box-shadow: var(--fab-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease, transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation; /* Good practice for buttons */
}

#dark-mode-toggle:hover {
    box-shadow: var(--fab-hover-shadow);
    transform: translateY(-3px); /* Slight lift effect */
}

#dark-mode-toggle:active {
    transform: scale(0.95); /* Press down effect */
    box-shadow: var(--fab-shadow); /* Reset shadow */
}

/* --- Footer --- */
.dashboard-footer {
    text-align: center;
    padding: 1rem calc(1.5rem + env(safe-area-inset-left)) calc(1rem + env(safe-area-inset-bottom)) calc(1.5rem + env(safe-area-inset-right));
    margin-top: auto; /* Push footer to bottom */
    font-size: 0.85rem;
    color: var(--text-muted-color);
    background-color: transparent; /* Let body background show through */
    border-top: 1px solid var(--border-color);
    width: 100%;
    transition: color var(--transition-speed) ease, border-color var(--transition-speed) ease;
    box-sizing: border-box;
}

.dashboard-footer p {
    margin: 0;
}

/* --- Error Message Styling (if fetch fails) --- */
.error-message {
    color: #e74c3c; /* Error color */
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    padding: 1rem;
    border-radius: var(--border-radius-md);
    text-align: center;
}

[data-theme="dark"] .error-message {
    color: #f88a7b; /* Lighter error red for dark bg */
    background-color: rgba(248, 138, 123, 0.15);
    border-color: rgba(248, 138, 123, 0.4);
}


/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    html { font-size: 15px; } /* Slightly smaller base font */

    .dashboard-header {
        padding-left: calc(1.5rem + env(safe-area-inset-left));
        padding-right: calc(1.5rem + env(safe-area-inset-right));
        padding-top: 0.8rem;
        padding-bottom: 0.6rem;
    }
    .dashboard-header h1 { font-size: 1.7rem; margin-bottom: 0.6rem; }
    .controls { gap: 0.6rem; margin-bottom: 0.6rem; }
    main {
        padding: 1.5rem;
        padding-bottom: calc(75px + env(safe-area-inset-bottom));
    }
    .services-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.5rem; }
    .service-tile a { padding: 1.2rem; }
    .service-tile h3 { font-size: 1.05rem; min-height: 36px; }
    .service-image-wrapper { width: 75px; height: 75px; margin-bottom: 1.2rem; }
    .tag-filters { margin: 0 1.5rem; }
    .tags-toggle-btn { width: calc(100% - 3rem); font-size: 0.85rem; padding: 0.35rem 1rem; margin-bottom: 0.6rem;}
    #dark-mode-toggle {
        width: 45px;
        height: 45px;
        bottom: calc(15px + env(safe-area-inset-bottom));
        right: calc(15px + env(safe-area-inset-right));
        font-size: 1.3rem;
    }
    .dashboard-footer { padding-left: 1rem; padding-right: 1rem; }
}

@media (max-width: 576px) {
     html { font-size: 14px; }

     .dashboard-header {
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
        padding-top: 0.6rem;
        padding-bottom: 0.5rem;
    }
     .dashboard-header h1 { font-size: 1.5rem; margin-bottom: 0.5rem;}
     .controls {
        flex-direction: column; /* Stack controls */
        align-items: stretch; /* Make controls take full width */
        gap: 0.6rem;
        margin-bottom: 0.6rem;
     }
     .controls > *, /* Target direct children of controls */
     .search-container { /* Ensure container takes full width */
        width: 100%;
        max-width: none; /* Override max-width */
     }
     .controls input[type="search"] {
         min-width: initial; /* Remove min-width */
         padding-right: 2.6rem; /* Ensure enough space for clear button */
     }
     .controls select {
         text-align: center; /* Center text in dropdown */
     }
     main {
        padding: 1rem;
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
     .tag-filters { margin: 0 1rem; }
     .tags-toggle-btn { width: calc(100% - 2rem); font-size: 0.8rem; padding: 0.3rem 1rem; margin-bottom: 0.5rem;}
     .tags-inner-collapsible { justify-content: flex-start; } /* Align tags left */
     .services-grid {
         grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); /* Smaller tiles */
         gap: 1rem;
     }
     .service-tile a { padding: 1rem; }
     .service-tile h3 { font-size: 0.95rem; min-height: 32px; }
     .service-image-wrapper { width: 65px; height: 65px; margin-bottom: 1rem; }
     #dark-mode-toggle {
        width: 40px;
        height: 40px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        right: calc(10px + env(safe-area-inset-right));
        font-size: 1.2rem;
    }
}