/* =====================
   DESIGN TOKENS
   ===================== */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-light: #94a3b8;

    /* Aliakset (MDI / teemat): sama semantiikka kuin design-dokumentissa */
    --color-background-primary: var(--color-bg);
    --color-background-secondary: var(--color-surface);
    --color-text-primary: var(--color-text);
    --color-border-tertiary: var(--color-border-light);

    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-danger-light: #fef2f2;

    --color-background-warning: #fffbeb;
    --color-border-warning: #fcd34d;
    --color-text-warning: #b45309;
    --border-radius-md: 6px;

    /* MDI: #mdi-taskbar ~15M, snap-splitterit/ikkunat; modaalin oltava päällimmäinen */
    --app-modal-z: 20000000;

    --sidebar-bg: #1a1d2e;
    --sidebar-surface: #1e2235;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --topbar-bg: #1a1d2e;
    --sidebar-text: #a0aec0;
    --modal-bg: #1e2237;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);

    /* Pystysuuntainen paneelien jako (splitter) – sama kaikissa näkymissä */
    --app-splitter-v-width: 7px;
}

/* =====================
   CANONICAL VERTICAL SPLITTER (pystysuunta, col-resize)
   ─────────────────────────────────────────────────────
   Käyttö: määrälaskenta (mittaukset | laskelma), laskelma (suorite | oikea paneeli),
   rakennusosapaneeli (suoritelista | mittatiedot).

   Säännöt:
   - Leveys: var(--app-splitter-v-width), älä käytä 5px/3px poikkeavia arvoja.
   - Tausta: surface, reunat: color-border; hover/drag: color-border-light (ei primary-täyttöä).
   - Kahva: pystysuuntaiset pisteet (·) HTML:ssä tai sama visuaalinen tiheys.
   - Luokka .dragging asetetaan JS:stä vetämisen ajaksi.

   Vanhat luokat (.ro-vsplitter, .ml-panel-splitter) → lisää .app-splitter-v rinnalle.
   ===================== */
.app-splitter-v {
    width: var(--app-splitter-v-width);
    flex-shrink: 0;
    box-sizing: border-box;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--color-text-muted);
    user-select: none;
    writing-mode: vertical-lr;
    line-height: 1.1;
}
.app-splitter-v:hover,
.app-splitter-v.dragging {
    background: var(--color-border-light);
}

/* Vaakasuuntainen jako (row-resize) — sama ulkoasu kuin EstimatePage rakennusosat (.ro-splitter);
   hieman tummempi raita kuin pelkkä border-bottom (tausta color-bg). */
.app-splitter-h {
    height: 7px;
    flex-shrink: 0;
    box-sizing: border-box;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--color-text-muted);
    user-select: none;
}
.app-splitter-h:hover,
.app-splitter-h.dragging {
    background: var(--color-border-light);
}

/* =====================
   LIGHT THEME OVERRIDES
   Apply by adding `theme-light` class on body or using `data-theme="light"`
   ===================== */
.theme-light,
[data-theme="light"] {
    --sidebar-bg: #ffffff;
    --topbar-bg: #ffffff;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e6eef8;

    --color-text: #0f172a;        /* primary text */
    --color-text-muted: #6b7280;  /* secondary text */
    --color-text-light: #9ca3af;  /* tertiary */
}

/* Sidebar and topbar */
.theme-light .sidebar,
[data-theme="light"] .sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--color-border);
}
.theme-light .topbar,
[data-theme="light"] .topbar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--color-border);
}

/* Nav items: use dark text on light theme and keep contrast on hover/active */
.theme-light .nav-item,
[data-theme="light"] .nav-item,
.theme-light .nav-item .nav-label,
[data-theme="light"] .nav-item .nav-label {
    color: var(--color-text);
}
.theme-light .nav-item:hover,
[data-theme="light"] .nav-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-text);
}
.theme-light .nav-item.active,
[data-theme="light"] .nav-item.active {
    background: rgba(37, 99, 235, 0.12);
    color: var(--color-primary);
}

/* Flyout panel should be light too */
.theme-light .nav-flyout-panel,
[data-theme="light"] .nav-flyout-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 24px rgba(16,24,40,0.06);
}
.theme-light .flyout-title,
[data-theme="light"] .flyout-title {
    color: var(--color-text-muted);
    border-bottom-color: var(--color-border);
}

/* Flyout items: dark text and subtle hover */
.theme-light .flyout-item,
[data-theme="light"] .flyout-item {
    color: var(--color-text);
    background: transparent;
}
.theme-light .flyout-item:hover,
[data-theme="light"] .flyout-item:hover {
    background: rgba(37, 99, 235, 0.06);
    color: var(--color-text);
}
.theme-light .flyout-item-label,
[data-theme="light"] .flyout-item-label {
    color: var(--color-text);
}
.theme-light .flyout-item-desc,
[data-theme="light"] .flyout-item-desc {
    color: var(--color-text-muted);
}
.theme-light .flyout-item-icon,
[data-theme="light"] .flyout-item-icon {
    background: #f1f5f9;
    color: #475569;
}

/* Bookmark button visibility and colors on light theme */
.theme-light .bookmark-btn,
[data-theme="light"] .bookmark-btn {
    color: rgba(15,23,42,0.4);
}
.theme-light .bookmark-btn:hover,
[data-theme="light"] .bookmark-btn:hover {
    background: rgba(0,0,0,0.06);
    color: var(--color-text-muted);
}
.theme-light .bookmark-btn.bookmarked,
[data-theme="light"] .bookmark-btn.bookmarked {
    color: var(--color-primary);
}
.theme-light .bookmark-btn.bookmarked:hover,
[data-theme="light"] .bookmark-btn.bookmarked:hover {
    background: rgba(37,99,235,0.1);
    color: var(--color-primary);
}

/* Ensure group labels are visible */
.theme-light .nav-group-label,
[data-theme="light"] .nav-group-label {
    color: rgba(15,23,42,0.45);
}

/* Settings-nav: hover ja aktiivinen tila vaaleassa teemassa */
.theme-light .settings-nav-item:hover,
[data-theme="light"] .settings-nav-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-text);
}
.theme-light .settings-nav-item.active,
[data-theme="light"] .settings-nav-item.active {
    background: rgba(37, 99, 235, 0.12);
    color: var(--color-primary);
}
.theme-light .settings-nav-item.active .settings-nav-icon,
[data-theme="light"] .settings-nav-item.active .settings-nav-icon {
    color: var(--color-primary);
}
.theme-light .settings-nav-brand,
[data-theme="light"] .settings-nav-brand {
    color: var(--color-text-muted);
    opacity: 1;
}

/* Nav-item hover: älä vaihda tekstin väriä valkoiseksi vaalealla teemalla */
.theme-light .nav-item:hover,
[data-theme="light"] .nav-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--sidebar-text);
}
/* Nav-item-parent open vaalealla teemalla */
.theme-light .nav-item-parent.open,
[data-theme="light"] .nav-item-parent.open {
    background: rgba(37, 99, 235, 0.06);
    color: var(--color-text);
}


/* =====================
   RESET & BASE
   ===================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

/* =====================
   APP SHELL
   ===================== */
.app-shell {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    width: 100%;
    padding: 24px;
    background: var(--color-bg);
}
/* EstimatePage käyttää koko leveyden – poistetaan sisäpadding.
   Muut sivut saavat normaalin padding:24px. */
.app-content:has(.estimate-root),
.app-content:has(.estimate-page-wrapper),
.app-content:has(.ml-root) {
    padding: 0 !important;
    overflow: hidden !important;
}

/* MDI-työpöytä: ei paddingia, täysi leveys; flex-ketju jotta .mdi-page täyttää korkeuden. */
.app-content:has(.mdi-page) {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.estimate-page-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden;
}

/* JS-luoma Win11-esikatselun nauha (desktopInterop.ensureSnapAssistPanel) — teemat CSS-muuttujista */
#mdi-desktop-area .mdi-snap-assist--floating {
    padding: 11px 12px;
    border-radius: 16px;
    background: var(--color-background-secondary, var(--color-surface));
    border: 0.5px solid var(--color-border-tertiary, var(--color-border));
    color: var(--color-text-primary, var(--color-text));
    box-shadow: var(--shadow);
}

/* =====================
   SIDEBAR
   ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
    /* Määrälaskennan vasemman palkin z-index 12–30 — flyoutin oltava päällä */
    z-index: 100;
    transition: width 0.22s ease;
}

.sidebar.collapsed {
    width: 60px;
}

/* Header */
.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
}

/* Collapsed header: vain K-ikoni keskitettynä */
.sidebar-logo-icon-only {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-favicon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--sidebar-text);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

/* Nav-alue */
.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    overflow: visible;         /* ei leikkaa absolute-flyoutia */
}

.sidebar.collapsed .sidebar-nav {
    padding: 8px 0;
}

/* Nav-ryhmät */
.nav-group {
    padding: 10px 0 4px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 2px;
}

.nav-group:last-child {
    border-bottom: none;
}

.nav-group-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--sidebar-text);
    opacity: 0.45;
    padding: 0 12px 6px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.1s ease;
}

.sidebar.collapsed .nav-group-label {
    opacity: 0;
    height: 0;
    padding: 0;
}

.nav-empty-hint {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    font-size: 12px;
    color: var(--sidebar-text);
    opacity: 0.3;
    font-style: italic;
    white-space: nowrap;
    transition: opacity 0.1s ease;
}

.sidebar.collapsed .nav-empty-hint {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

/* Nav-linkit */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, padding 0.22s ease, gap 0.22s ease, width 0.22s ease;
    cursor: pointer;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    line-height: 1.4;
    position: relative;
    overflow: visible;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: white;
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.28);
    color: #93c5fd;
}

.nav-item.active .nav-icon {
    color: #60a5fa;
}

/* Collapsed nav-item – ikonikeskitys */
.sidebar.collapsed .nav-item {
    width: 60px;
    padding: 10px 0;
    justify-content: center;
    align-items: center;
    gap: 0;
    border-radius: 0;
    margin: 0;
}

/* Alavalikko-parent */
.nav-item-parent.open {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
}

/* Nav-label */
.nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.22s ease, flex 0.22s ease, max-width 0.22s ease;
}

.sidebar.collapsed .nav-label {
    opacity: 0;
    flex: 0 0 0px;
    min-width: 0;
    max-width: 0;
    overflow: hidden;
}

/* Flyout-wrapper: containing block absolutelle flyoutille */
.nav-flyout-wrapper {
    position: relative;
}

/* Chevron */
.nav-chevron {
    margin-left: auto;
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    transition: opacity 0.1s ease;
}

.nav-item-parent.open .nav-chevron {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar.collapsed .nav-chevron {
    opacity: 0;
    flex: 0 0 0px;
    min-width: 0;
    max-width: 0;
    overflow: hidden;
    margin: 0;
}

.nav-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: inherit;
}

/* =====================
   TOOLTIP (collapsed-tila)
   ===================== */
.sidebar.collapsed .nav-item[data-tooltip]::after,
.sidebar.collapsed .sidebar-user-avatar[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--modal-bg);
    color: rgba(255, 255, 255, 0.92);
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar.collapsed .nav-item[data-tooltip]:hover::after,
.sidebar.collapsed .sidebar-user-avatar[data-tooltip]:hover::after {
    opacity: 1;
}

/* =====================
   FLYOUT-PANEELI
   ===================== */
@keyframes flyout-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.nav-flyout-panel {
    position: absolute;
    left: 100%;                /* suoraan wrapper-divin oikealle puolelle */
    top: 0;
    margin-left: 0;            /* ei väliä – varmistaa sujuvan hover-siirtymän */
    z-index: 150;
    min-width: 220px;
    background: var(--modal-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
    animation: flyout-in 0.15s ease;
}

.flyout-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--sidebar-text);
    opacity: 0.5;
    padding: 6px 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 4px;
}

.flyout-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.flyout-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 7px;
    text-decoration: none;
    color: var(--sidebar-text);
    transition: background 0.12s ease, color 0.12s ease;
    cursor: pointer;
}

.flyout-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: white;
}

.flyout-item.active {
    background: rgba(37, 99, 235, 0.28);
    color: #93c5fd;
}

.flyout-item.active .flyout-item-icon {
    color: #60a5fa;
}

.flyout-item-icon {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.5);
    transition: background 0.12s ease;
}

.flyout-item:hover .flyout-item-icon {
    background: rgba(255, 255, 255, 0.1);
}

.flyout-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.flyout-item-label {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
}

.flyout-item-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.2;
}

.flyout-item.active .flyout-item-desc {
    color: rgba(147, 197, 253, 0.5);
}

/* Käyttäjäosio – kiinnitetty sidebarin alareunaan */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
    margin-top: auto;
    transition: padding 0.22s ease, gap 0.22s ease;
}

.sidebar.collapsed .sidebar-user {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    width: 60px;
    gap: 6px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: rgba(37, 99, 235, 0.5);
    color: #93c5fd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    position: relative;
    cursor: default;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    transition: opacity 0.22s ease, max-width 0.22s ease;
    max-width: 200px;
}

.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--sidebar-text);
    opacity: 0.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    opacity: 0.5;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease, opacity 0.1s ease;
    flex-shrink: 0;
}

.sidebar-logout:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.sidebar.collapsed .sidebar-logout {
    opacity: 0.5;
    padding: 5px;
}

/* =====================
   BOOKMARK BUTTONS
   ===================== */

/* Wrapper on flex-rivi: nav-item kasvaa, bookmark-nappi pysyy kiinteänä */
.nav-item-wrapper {
    display: flex;
    align-items: center;
}

.nav-item-wrapper > .nav-item {
    flex: 1;
    min-width: 0;
    width: auto; /* poistaa width:100% flex-contextissa */
}

.flyout-item-wrapper {
    display: flex;
    align-items: center;
}

.flyout-item-wrapper > .flyout-item {
    flex: 1;
    min-width: 0;
}

/* Bookmark-nappi on flex-item wrapper-rivillä, margin-left:-28px tekee visuaalisen
   päällekkäisyyden nav-itemin oikean reunan kanssa */
.bookmark-btn {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    margin-left: -26px;       /* vedetään nav-itemin oikean reunan päälle */
    position: relative;
    z-index: 1;               /* näkyy nav-itemin päällä */
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
    line-height: 0;
}

.nav-item-wrapper:hover .bookmark-btn,
.flyout-item-wrapper:hover .bookmark-btn {
    opacity: 1;
}

.bookmark-btn.bookmarked {
    opacity: 1;
    color: #60a5fa;
}

.bookmark-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
}

.bookmark-btn.bookmarked:hover {
    color: #f87171;
}

.sidebar.collapsed .bookmark-btn {
    display: none;
}

/* =====================
   ANNOUNCEMENT BANNER
   ===================== */
.announcement-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    flex-shrink: 0;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
    z-index: 50;
}
.announcement-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.announcement-banner-content svg {
    opacity: 0.9;
}
.announcement-banner-content span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
}
.announcement-banner-close {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.announcement-banner-close:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}

/* =====================
   TOPBAR
   ===================== */
.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* =====================
   SEARCH TRIGGER
   ===================== */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--sidebar-border);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--border-radius);
    padding: 6px 12px;
    font-size: 13px;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    width: min(360px, 100%);
    text-align: left;
    font-family: inherit;
}

.search-trigger:hover {
    background: var(--sidebar-border);
    border-color: var(--sidebar-text);
    color: var(--sidebar-text);
    opacity: 0.9;
}

.search-placeholder {
    flex: 1;
}

.shortcut {
    font-size: 11px;
    background: var(--sidebar-border);
    border: 1px solid var(--sidebar-border);
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--sidebar-text);
    opacity: 0.6;
    white-space: nowrap;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* =====================
   SEARCH MODAL
   ===================== */
@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 90px;
    animation: overlay-in 0.12s ease;
}

.search-modal {
    width: 640px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 180px);
    background: var(--modal-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7), 0 4px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-in 0.15s ease;
}

/* Modal header */
.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.search-modal-icon {
    color: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.search-modal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 17px;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.9);
    caret-color: #60a5fa;
    min-width: 0;
}

.search-modal-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.search-modal-esc {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    padding: 3px 9px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.12s ease, color 0.12s ease;
}

.search-modal-esc:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.65);
}

/* Modal body */
.search-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.search-modal-body::-webkit-scrollbar {
    width: 6px;
}

.search-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.search-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

/* Result groups */
.search-group {
    padding: 6px 0 2px;
}

.search-group + .search-group {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 2px;
    padding-top: 8px;
}

.search-group-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.28);
    padding: 2px 20px 6px;
}

/* Result items */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.1s ease;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.search-result-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.45);
    transition: background 0.1s ease, color 0.1s ease;
}

.search-result-item:hover .search-result-icon {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.75);
}

.search-result-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.search-result-name {
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-sub {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.32);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-arrow {
    color: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.1s ease, transform 0.1s ease;
}

.search-result-item:hover .search-result-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* No results */
.search-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 44px 20px;
    color: rgba(255, 255, 255, 0.25);
    text-align: center;
    font-size: 13.5px;
    line-height: 1.5;
}

.search-no-results strong {
    color: rgba(255, 255, 255, 0.45);
}

/* Modal footer */
.search-modal-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.22);
    flex-shrink: 0;
}

.search-modal-footer kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--sidebar-border);
    color: var(--sidebar-text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.topbar-company {
    font-size: 13px;
    color: var(--sidebar-text);
}

.topbar-logo {
    height: 28px;
    max-width: 120px;
    object-fit: contain;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* =====================
   FLYOUT EMPTY STATE
   ===================== */
.flyout-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    color: var(--sidebar-text);
    opacity: 0.45;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
}

/* =====================
   PAGE HEADER
   ===================== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.4px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 3px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* =====================
   CARD PANEL
   ===================== */
.card-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.card-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.card-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.card-panel-body {
    padding: 20px;
}

/* =====================
   EMPTY STATE
   ===================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 13px;
    color: var(--color-text-muted);
    max-width: 320px;
    margin-bottom: 20px;
}

/* =====================
   BUTTONS
   ===================== */
.btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-danger:hover {
    background: var(--color-danger-light);
}

/* =====================
   TABLES
   ===================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-border-light);
    white-space: nowrap;
}

.data-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: var(--color-border-light);
    cursor: pointer;
}

.data-table tbody tr.selected {
    background: var(--color-primary-light);
}

/* =====================
   BADGES / STATUS
   ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-active {
    background: var(--color-success-light);
    color: var(--color-success);
}

.badge-draft {
    background: var(--color-border-light);
    color: var(--color-text-muted);
}

.badge-completed {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-archived {
    background: #fef3c7;
    color: #92400e;
}

/* =====================
   FORMS
   ===================== */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}

.form-input {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.15s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.15s ease;
    outline: none;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* =====================
   UTILITIES
   ===================== */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.font-mono { font-family: 'Courier New', monospace; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* =====================
   MODAL
   ===================== */
@keyframes modal-fade-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: var(--app-modal-z);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-dialog {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    width: 520px;
    max-width: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: modal-fade-in 0.15s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}

.modal-close:hover {
    background: var(--color-border-light);
    color: var(--color-text);
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 24px 20px;
}

/* =====================
   TABS
   ===================== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
}

.tab-item {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.12s ease, border-color 0.12s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 7px;
}

.tab-item:hover {
    color: var(--color-text);
}

.tab-item.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* =====================
   STATUS BADGE VARIANTS
   ===================== */
.badge-completed {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-archived {
    background: #fef3c7;
    color: #92400e;
}

/* =====================
   SETTINGS PAGE
   ===================== */
.settings-shell {
    display: flex;
    margin: -24px;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
}

.settings-shell--mdi {
    margin: 0;
    height: 100%;
    min-height: 0;
}

/* Left nav */
.settings-nav {
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-surface);
    border-right: 1px solid var(--color-border);
    padding: 20px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-brand {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--sidebar-text);
    opacity: 0.5;
    padding: 2px 12px 14px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--sidebar-text);
    transition: background 0.12s ease, color 0.12s ease;
}

.settings-nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: white;
}

.settings-nav-item.active {
    background: rgba(37, 99, 235, 0.28);
    color: #93c5fd;
    font-weight: 600;
}

.settings-nav-icon {
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--sidebar-text);
}

.settings-nav-item.active .settings-nav-icon {
    color: #93c5fd;
}

/* Right content */
.settings-main {
    flex: 1;
    padding: 28px 36px;
    overflow-y: auto;
    min-width: 0;
}

.settings-header {
    margin-bottom: 24px;
}

.settings-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.3px;
    margin: 0 0 4px;
}

.settings-header p {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0;
}

/* Settings sections */
.settings-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}

.settings-section-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-border-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    /* Käyttää CSS-muuttujia – päivittyy teeman vaihtuessa */
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    gap: 24px;
    min-height: 64px;
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-label {
    flex: 1;
    min-width: 0;
}

.settings-row-label strong {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 2px;
}

.settings-row-label span {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.settings-row-control {
    flex-shrink: 0;
}

.settings-row-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-unit {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* Color picker */
.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-border-light);
    border: 1px solid var(--color-border);
    border-radius: 9px;
    padding: 5px 12px 5px 5px;
    transition: border-color 0.12s ease;
    cursor: pointer;
}

.color-picker-wrap:hover {
    border-color: #94a3b8;
}

.color-picker-swatch {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0;
    cursor: pointer;
    background: none;
}

.color-picker-value {
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
    min-width: 60px;
}

/* Inputs */
.settings-select,
.settings-input {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 13.5px;
    color: var(--color-text);
    background: var(--color-surface);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.settings-select {
    min-width: 200px;
    cursor: pointer;
}

.settings-input {
    min-width: 240px;
}

.settings-input-sm {
    min-width: 120px;
}

.settings-input-xs {
    min-width: 80px;
}

.settings-select:focus,
.settings-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Toggle switch */
.toggle-wrap {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-wrap input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 12px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-wrap input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle-wrap input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* Number preview */
.number-preview {
    display: inline-flex;
    align-items: center;
    background: var(--color-border-light);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    color: var(--color-text);
    letter-spacing: 0.5px;
}

/* Integration items */
.integration-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    gap: 16px;
}

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

.integration-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.integration-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: var(--color-border-light);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.integration-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 3px;
}

.integration-desc {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Coming soon badge */
.badge-coming-soon {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    background: var(--color-border-light);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* Placeholder content */
.settings-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--color-text-light);
    text-align: center;
    font-size: 13px;
    line-height: 1.6;
}

/* Save bar */
.settings-save-bar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 4px;
}

/* Toast */
@keyframes toast-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.settings-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 9px;
    animation: toast-slide-in 0.2s ease;
}

.settings-toast svg {
    color: #4ade80;
    flex-shrink: 0;
}

/* ── Activity Log ── */
.activity-log { display:flex; flex-direction:column; gap:0; }
.activity-item { display:flex; gap:12px; padding:12px 0; border-bottom:1px solid var(--color-border-light); align-items:flex-start; }
.activity-item:last-child { border-bottom:none; }
.activity-icon { width:32px; height:32px; border-radius:8px; background:var(--color-surface); border:1px solid var(--color-border); display:flex; align-items:center; justify-content:center; flex-shrink:0; color:var(--color-primary); }
.activity-body { flex:1; min-width:0; }
.activity-header { display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; }
.activity-type { font-size:11px; font-weight:600; color:var(--color-text-muted); text-transform:uppercase; letter-spacing:.04em; }
.activity-subject { font-size:13.5px; font-weight:600; color:var(--color-text); }
.activity-meta { font-size:11.5px; color:var(--color-text-muted); margin-top:2px; }
.activity-notes { font-size:12.5px; color:var(--color-text); margin-top:6px; line-height:1.5; background:var(--color-surface); border-radius:6px; padding:6px 10px; }
.activity-actions { display:flex; gap:4px; opacity:0; transition:opacity .15s; }
.activity-item:hover .activity-actions { opacity:1; }
.activity-type-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; margin-bottom:12px; }
.activity-type-btn { display:flex; flex-direction:column; align-items:center; gap:4px; padding:8px 4px; border:1px solid var(--color-border); border-radius:8px; background:var(--color-surface); cursor:pointer; font-size:11px; color:var(--color-text-muted); transition:border-color .15s, color .15s; }
.activity-type-btn.selected { border-color:var(--color-primary); color:var(--color-primary); background:rgba(37,99,235,.06); }
.activity-type-btn:hover:not(.selected) { border-color:var(--color-border); background:var(--color-surface); color:var(--color-text); }

/* ── Dashboard ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.dashboard-widget {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow .2s, border-color .2s;
}
.dashboard-widget:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: var(--color-border); }

.dashboard-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 0;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}
.dashboard-widget-body {
    padding: 12px 18px 16px;
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    color: var(--color-text);
}

/* Dashboard widget row (replaces old widget-list) */
.dw-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--color-border-light, rgba(0,0,0,0.04));
    text-decoration: none;
    color: inherit;
    transition: background .1s;
}
.dw-row:last-child { border-bottom: none; }
a.dw-row:hover { background: var(--color-bg); margin: 0 -18px; padding-left: 18px; padding-right: 18px; border-radius: 6px; }
.dw-row-name { font-weight: 500; color: var(--color-text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
a.dw-row:hover .dw-row-name { color: var(--color-primary); }
.dw-row-meta { font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; flex-shrink: 0; }

/* Dashboard empty inside widget */
.dw-empty { text-align: center; padding: 24px 8px; color: var(--color-text-muted); font-size: 13px; }

.dashboard-widget-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}
.dashboard-editing .dashboard-widget-actions { opacity: 1; }

.dashboard-widget-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    color: var(--color-text-muted);
    font-size: 14px;
}
.dashboard-widget-actions button:hover { color: var(--color-text); background: var(--color-bg); }

.dashboard-editing .dashboard-widget {
    border: 2px dashed var(--color-primary);
    cursor: grab;
}
.dashboard-editing .dashboard-widget.sortable-ghost { opacity: 0.4; }
.dashboard-editing .dashboard-widget.sortable-chosen { box-shadow: 0 4px 20px rgba(0,0,0,0.15); }

/* Status badges */
.widget-status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.widget-status-badge.active { background: rgba(34,197,94,.12); color: #16a34a; }
.widget-status-badge.completed { background: rgba(59,130,246,.12); color: #2563eb; }
.widget-status-badge.archived { background: rgba(107,114,128,.12); color: #6b7280; }
.widget-status-badge.draft { background: rgba(234,179,8,.12); color: #ca8a04; }

/* Quick actions grid */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: border-color .15s, background .15s, color .15s;
}
.quick-action-btn:hover { border-color: var(--color-primary); background: rgba(37,99,235,.06); color: var(--color-primary); }
.quick-action-btn svg { flex-shrink: 0; color: var(--color-primary); }

/* Dashboard empty state */
.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: 16px;
}
.dashboard-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.dashboard-empty h2 { font-size: 20px; color: var(--color-text); margin: 0 0 8px; font-weight: 700; }
.dashboard-empty p { font-size: 14px; margin: 0 0 20px; }

/* Widget add modal */
.widget-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--app-modal-z);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.widget-modal {
    background: var(--color-surface);
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.widget-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-size: 16px;
    font-weight: 700;
}
.widget-modal-body { padding: 16px 20px; }

.widget-category-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    margin: 16px 0 8px;
}
.widget-category-title:first-child { margin-top: 0; }

.widget-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 6px;
    transition: border-color .15s;
}
.widget-option:hover { border-color: var(--color-primary); }
.widget-option.added { opacity: 0.5; }
.widget-option-info { flex: 1; min-width: 0; }
.widget-option-name { font-size: 13.5px; font-weight: 600; color: var(--color-text); }
.widget-option-desc { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

/* Widget settings mini-modal */
.widget-settings-popup {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 12px 14px;
    min-width: 220px;
}
.widget-settings-popup label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.widget-settings-popup select,
.widget-settings-popup input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13px;
    margin-bottom: 8px;
}
.widget-settings-popup .btn-sm { padding: 4px 12px; font-size: 12px; }

/* Chart container */
.widget-chart-container { position: relative; width: 100%; height: 150px; }
.widget-chart-container canvas { width: 100% !important; height: 100% !important; }

/* Widget size classes */
.widget-w1 { grid-column: span 1; }
.widget-w2 { grid-column: span 2; }
.widget-w3 { grid-column: span 3; }
.widget-w4 { grid-column: span 4; }
.widget-h1 { }
.widget-h2 { min-height: 340px; }
.widget-h3 { min-height: 500px; }
@media (max-width: 600px) {
    .widget-w1, .widget-w2, .widget-w3, .widget-w4 { grid-column: span 1; }
}

/* Tulossa pian — disabloidut toiminnot */
.btn-disabled-soon {
    opacity: 0.5;
    cursor: not-allowed !important;
    position: relative;
}

.btn-disabled-soon::after {
    content: "Tulossa pian";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 4px;
    background: var(--color-background-secondary, var(--color-surface));
    border: 0.5px solid var(--color-border-tertiary, var(--color-border));
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    white-space: nowrap;
    display: none;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: var(--color-text-primary, var(--color-text));
}

.btn-disabled-soon:hover::after {
    display: block;
}
