@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600');

/* =========================================
   Design Tokens
   ========================================= */
:root {
  /* Brand */
  --color-primary: #5f78c8;
  --color-secondary: #d9dee8;
  --color-primary-hover: #6f88d6;
  --header-control-bg: linear-gradient(180deg, #fbfcfe 0%, #e3e9f2 100%);
  --header-control-hover-bg: linear-gradient(180deg, #ffffff 0%, #eaf0f7 100%);
  --header-control-active-bg: linear-gradient(180deg, #dde4ef 0%, #d2dbe8 100%);
  --header-control-color: #1f2736;

  /* States */
  --state-ok-color: #22c55e;
  --state-sale-color: #0077ff;
  --state-stolen-color: #e11d48;
  --state-broken-color: #f59e0b;
  --state-repair-color: #8b5cf6;
  --state-lost-color: #6b7280;

  --surface-base: #ffffff;
  --surface-alt: #111827;
  --gray-50: #f4f6fa;
  --gray-75: #eef1f6;
  --gray-100: #e7ecf3;
  --gray-150: #dde3ed;
  --gray-200: #d3dbe8;
  --gray-250: #c5cfde;
  --gray-300: #b6c2d4;
  --gray-400: #96a4bb;
  --gray-500: #66748b;
  --gray-600: #334155;
  --gray-700-soft: #475569;
  --gray-800-soft: #243144;
  --gray-900-soft: #182335;
  --surface-alt-strong: #c7d0df;

  /* Backgrounds */
  --color-background-body: #eff1f5;
  --color-background-login: #d9dee8;
  --header-color: #eff1f5;

  /* Gradients */
  --gradient-body: none;
  --gradient-press-start: #5a73bf;
  --gradient-press-end: #4d67b2;

  /* Typography */
  --font-family-base: "Open Sans", sans-serif;
  --font-size-display:36px;
  --font-size-h1:32px;
  --font-size-h2:28px;
  --font-size-h3:26px;
  --font-size-h4:22px;
  --font-size-h5:20px;
  --font-size-h6:18px;
  --font-size-base:20px;
  --font-size-l:20px;
  --font-size-m:16px;
  --font-size-s:14px;
  --font-size-xs:12px;
  --font-size-label:11px;
  --line-height-base: 1.5;

  /* Spacing */
  --space-none:0;
  --space-xs:4px;
  --space-s:8px;
  --space-base:16px;
  --space-m:24px;
  --space-l:32px;
  --space-xl:40px;
  --space-xxl:48px;

  /* Layout sizes */
  --header-size:56px;
  --header-size-content:48px;
  --header-control-size:44px;
  --header-control-icon-size: 24px;
  --header-tools-gap: 6px;
  --side-menu-size:300px;
  --bottom-bar-size:56px;
  --footer-height:0px;
  --content-max: 1280px;
  --size-nav-toggle:44px;
  --size-avatar:40px;
  --size-select-max: 18ch;
  --size-media-max: 600px;
  --content-form-max: 800px;
  --size-checkbox-touch: 22px;

  /* Radii */
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 24px;
  --radius-pill: 999px;

  /* Borders & Outlines */
  --header-control-border: rgba(148, 163, 184, 0.28);
  --header-control-hover-border: rgba(95, 120, 200, 0.34);
  --border: 1px solid rgba(30, 41, 59, 0.12);
  --border-subtle: 1px solid rgba(30, 41, 59, 0.08);
  --border-strong: 1px solid rgba(30, 41, 59, 0.18);
  --border-soft: 1px solid rgba(30, 41, 59, 0.10);
  --focus-ring: 0 0 0 2px rgba(95, 120, 200, 0.20);
  --delete-red: #dc2626;

  /* Shadows */
  --header-control-shadow:
    inset 0 1px 0 rgba(255,255,255,0.75),
    0 2px 8px rgba(71, 88, 122, 0.10);
  --shadow-xs: none;
  --shadow-s: none;
  --shadow-m: none;
  --shadow-l: none;
  --shadow-soft-elevated: none;
  --shadow-header: none;
  --shadow-sticky: 0 -6px var(--space-base) rgba(15, 23, 42, 0.08);

  /* Elevation */
  --layer-header:1000;

  /* Animation / Transitions */
  --easing: ease;
  --duration-fast: .18s;
  --duration-base: .2s;
  --transition-base: all var(--duration-base) linear;

  /* Accents */
  --accent: #0077ff;

  /* Semantic text colors */
  --text-strong: #1f2937;
  --text-default: #334155;
  --text-subtle-strong: #64748b;
  --text-on-accent: #ffffff;


  /* Status surfaces */
  --error-strong: #ff0000;
  --error-bg-soft: #ffe5e5;
  --error-bg: #ffe0e0;
  --error-text: #a00000;
  --error-border: #d00000;

  --success-bg: #e0ffe0;
  --success-text: #007000;
  --success-border: #00a000;

  --warning-bg: #fff4e0;
  --warning-text: #a06000;
  --warning-border: #d08000;

  /* Table / hover */
  --row-hover-bg: rgba(95, 120, 200, 0.08);

  /* Tooltips / overlays */
  --surface-hover-soft: rgba(30, 41, 59, 0.04);
  --tooltip-bg: #223250;
  --overlay-backdrop-strong: rgba(8, 23, 52, 0.65);
  --overlay-backdrop-medium: rgba(8, 23, 52, 0.55);
  --overlay-backdrop-light: rgba(8, 23, 52, 0.72);

  /* Chat */
  --chat-me-bg: rgba(95, 120, 200, 0.12);
  --chat-me-border: rgba(95, 120, 200, 0.35);

  /* Bulkbar / sticky bar */
  --bulkbar-bg: #dde3ed;
  --bulkbar-border: rgba(30, 41, 59, 0.12);

  /* Progress */
  --progress-bg: #cfd7e4;
  --progress-fill: #5f78c8;

  /* Icons / SVG */
  --svg-stroke-default: var(--gray-600);
  --select-arrow-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  /* Brand / links */
  --color-primary: #dbe6ff;
  --color-secondary: #223250;
  --color-primary-hover: #ffffff;
  --header-control-color: #f4f7fb;
  --header-control-bg: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.08) 100%);
  --header-control-hover-bg: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.11) 100%);
  --header-control-active-bg: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.20) 100%);
  --header-control-hover-border: rgba(255,255,255,0.26);
  --header-control-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    0 4px var(--space-base) rgba(0, 0, 0, 0.18);


  --surface-base: #223250;
  --surface-alt: #f8fbff;
  --gray-50: #081734;
  --gray-75: #102140;
  --gray-100: #162746;
  --gray-150: #1b2d4b;
  --gray-200: #223250;
  --gray-250: #324261;
  --gray-300: #47587a;
  --gray-400: #7081a0;
  --gray-500: #a9b7cf;
  --gray-600: #edf3ff;
  --color-background-body: #081734;
  --color-background-login: #102140;
  --header-color: #081734;
  --surface-alt-strong: #223250;

  /* Typography */
  --text-strong: #f4f7fb;
  --text-default: #e4ebf5;
  --text-subtle-strong: #b5c1d6;
  --text-on-accent: #f8fbff;

  /* Accent & states */
  --accent: #6f88d6;

  /* Gradients */
  --gradient-body: none;
  --gradient-press-start: #667fd0;
  --gradient-press-end: #5871be;

  /* Status backgrounds (soft on dark) */
  --error-bg: rgba(248, 113, 113, 0.12);
  --error-bg-soft: rgba(248, 113, 113, 0.08);
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning-bg: rgba(234, 179, 8, 0.12);

  /* Chat bubble "me" */
  --chat-me-bg: rgba(96, 165, 250, 0.12);
  --chat-me-border: rgba(96, 165, 250, 0.4);

  --header-control-border: rgba(255, 255, 255, 0.14);

  /* Table / hover */
  --row-hover-bg: rgba(111, 136, 214, 0.14);

  /* Tooltip / overlays */
  --tooltip-bg: #0c1d40;
  --overlay-backdrop-strong: rgba(8, 23, 52, 0.82);
  --overlay-backdrop-medium: rgba(8, 23, 52, 0.76);
  --overlay-backdrop-light: rgba(8, 23, 52, 0.72);

  /* Bulk bar */
  --bulkbar-bg: #0c1d40;
  --bulkbar-border: rgba(255,255,255,0.10);

  /* Progress */
  --progress-bg: #1b2d4b;
  --progress-fill: #6f88d6;
}


/* =========================================
   Utilities & Global
   ========================================= */
.state--ok        { color: var(--state-ok-color) }
.state--for-sale  { color: var(--state-sale-color) }
.state--stolen    { color: var(--state-stolen-color) }
.state--broken    { color: var(--state-broken-color) }
.state--repairing { color: var(--state-repair-color) }
.state--lost      { color: var(--state-lost-color) }

.state-icon { display: inline-flex; align-items: center; gap: .4em; }
.state-icon svg { vertical-align: middle; }

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

html { overflow-x: hidden; }

body {
  background-color: var(--color-background-body);
  /*background: var(--gradient-body);*/
  direction: ltr;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  font-family: var(--font-family-base);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--text-default);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-strong);
}

/* Links */
a, a:visited {
  color: var(--color-primary);
  transition: var(--transition-base);
  text-decoration: none;
}
a:hover, a:focus {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* Headers & page chrome */
header {
  background-color: var(--header-color);
  box-shadow: none;/*var(--shadow-header);*/
  border-bottom: var(--border);
  left: 0;
  position: sticky;
  right: 0;
  top: 0;
  width: 100%;
  z-index: var(--layer-header);
}

.header-control {
  width: var(--header-control-size);
  height: var(--header-control-size);
  min-width: var(--header-control-size);
  min-height: var(--header-control-size);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;

  border-radius: var(--radius-m);
  border: 1px solid var(--header-control-border);
  background: var(--header-control-bg);
  box-shadow: var(--header-control-shadow);

  color: var(--header-control-color);

  padding: 0;
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;

  transition:
    background var(--duration-fast) var(--easing),
    border-color var(--duration-fast) var(--easing),
    box-shadow var(--duration-fast) var(--easing),
    transform 0.12s ease;

}

.header-control:hover {
  background: var(--header-control-hover-bg);
  border-color: var(--header-control-hover-border);
}

.header-control:active {
  background: var(--header-control-active-bg);
  transform: translateY(1px);
}

.header-tools {
  display: inline-flex;
  align-items: center;
  gap: var(--header-tools-gap);
}

.header-control svg {
  width: var(--header-control-icon-size);
  height: var(--header-control-icon-size);
  flex: 0 0 auto;
}

.header-control--select {
  align-self: center;
  position: relative;
  inline-size: auto;
  min-inline-size: 0;
  block-size: var(--header-control-size);
  min-block-size: var(--header-control-size);
  padding-left: var(--space-s);
  padding-right: var(--space-base);
  border-radius: var(--radius-m);
}


.header-control--select::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translateY(-50%);
  pointer-events: none;
  background-image: var(--select-arrow-icon);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 8px;
}



.header-control--select select {
  width: 2ch;
  min-width: 2ch;
  max-width: 2ch;

  height: 100%;
  min-height: 0;

  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;

  background: transparent;
  background-image: none;

  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1;

  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  text-align: left;
  text-indent: 0;
}



header, main, footer {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  box-sizing: border-box;
}

.header-content {
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding-inline: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  min-height: var(--header-size);
  text-align: left;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-s);
}
.nav > * { display: inline-flex; align-items: center; margin: 0; }

.menu-logo {
  height: clamp(32px, 6vw, 44px);
  width: auto;
}

.nav-links,
.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-base);
  flex-wrap: wrap;
}

header select { max-width: var(--size-select-max); }

.nav-toggle {
  padding: 0;
  line-height: 0;
  flex: 0 0 auto;
}

.site-header {
  overflow: visible;
}

.site-header .header-content {
  gap: var(--space-s);
  overflow: visible;
  position: relative;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: static;
  transform: none;
  z-index: auto;
  pointer-events: auto;
}

.site-header .menu-logo {
  height: clamp(32px, 6vw, 44px);
  width: auto;
  display: block;
}

/* Base role switcher style */
.site-header .role-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.3rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid transparent;

  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;

  color: var(--text-color, inherit);
  background: transparent;

  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.1s ease;
}

/* Inactive roles */
.site-header .role-switcher:not(.selected) {
  border-color: color-mix(in srgb, currentColor 12%, transparent);
}

/* Hover / focus */
.site-header .role-switcher:not(.selected):hover,
.site-header .role-switcher:not(.selected):focus-visible {
  background: color-mix(in srgb, currentColor 8%, transparent);
  border-color: color-mix(in srgb, currentColor 25%, transparent);
  text-decoration: none;
}

/* Active role */
.site-header .role-switcher.selected {
  background: var(--color-primary, #1f6feb);
  color: var(--color-primary-contrast, #fff);
  border-color: var(--color-primary, #1f6feb);

  /* subtle highlight ring */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #1f6feb) 20%, transparent);
}

/* Active hover (keep stable, just slight feedback) */
.site-header .role-switcher.selected:hover,
.site-header .role-switcher.selected:focus-visible {
  filter: brightness(0.96);
  text-decoration: none;
}

/* Current role indicator dot */
.site-header .role-switcher.selected::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

/* Click feedback */
.site-header .role-switcher:active {
  transform: translateY(1px);
}

/* Spacing: separate roles from main nav */
.site-header a[href="/tili"] + .role-switcher {
  margin-left: 0.4rem;
}

.footer--desktop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-s);
}

.footer--desktop .align-right {
  float: none;
}

.footer-mobile-nav {
  display: none;
}

@media (max-width: 480px) {
  .nav-toggle {
    inline-size: var(--size-nav-toggle);
    block-size: var(--size-nav-toggle);
    padding: var(--space-s);
    flex: 0 0 auto;
  }

  .nav-toggle,
  .nav-toggle:hover,
  .nav-toggle:focus,
  .nav-toggle:active {
    box-shadow: var(--header-control-shadow);
  }

  .nav-toggle svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  .site-header {
    overflow: visible;
    isolation: isolate;
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .site-header .header-content {
    position: relative;
    max-width: 100vw;
    padding-left: max(var(--space-base), env(safe-area-inset-left));
    padding-right: max(var(--space-base), env(safe-area-inset-right));
    overflow: visible;
  }

  .site-header .brand {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, -50%);
    z-index: calc(var(--layer-header) + 10);
  }

  .site-header .menu-logo {
    height: 100px;
    width: auto;
  }

  .content {
    position: relative;
    padding-top: 28px;
    z-index: 1;
  }

  .nav {
    display: none;
    position: fixed;
    top: var(--header-size);
    left: 0;
    right: 0;
    background: var(--header-color);
    box-shadow: var(--shadow-header);
    border-bottom: var(--border-subtle);
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-block: var(--space-s);
    flex-direction: column;
    gap: var(--space-s);
    box-sizing: border-box;
    inset-inline: 0;
    z-index: calc(var(--layer-header) + 20);
    width: 100%;
    max-width: none;
    overflow-x: hidden;
  }
  .nav.is-open { display: flex; }

  .nav-links,
  .nav-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-s);
  }

  .nav a, .nav select { padding: var(--space-s) 0; }

  header { padding-left: 0; padding-right: 0; }

  .header-content {
    position: relative;
    max-width: 100vw;
    padding-left: max(var(--space-base), env(safe-area-inset-left));
    padding-right: max(var(--space-base), env(safe-area-inset-right));
  }

  #serialInput {
    max-width: 25ch;
  }

  .footer--desktop {
    display: none;
  }

  .footer-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--layer-header) + 5);

    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: stretch;

    background: var(--surface-base);
    border-top: var(--border);
    box-shadow: var(--shadow-sticky);
    padding-bottom: max(var(--space-xs), env(safe-area-inset-bottom));
  }

  .footer-mobile-nav__item {
    min-height: 64px;
    padding: var(--space-s) var(--space-xs);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    text-decoration: none;
    color: var(--text-default);
  }

  .footer-mobile-nav__item:visited {
    color: var(--text-default);
  }

  .footer-mobile-nav__item:hover,
  .footer-mobile-nav__item:focus {
    background: var(--surface-hover-soft);
    color: var(--color-primary);
    text-decoration: none;
  }

  .footer-mobile-nav__item svg {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
  }

  .footer-mobile-nav__item span {
    font-size: var(--font-size-xs);
    line-height: 1.2;
  }

  /* Prevent content from hiding behind fixed bottom nav */
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
}

/* --- Desktop layout --- */
@media (min-width: 481px) {
  .nav-toggle { display: none; }
  .nav {
    position: static;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: var(--space-base);
    min-width: 0;
    flex-wrap: nowrap;
  }
  .nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .nav-links > a {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    flex: 0 0 auto;
    min-width: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .nav-actions select {
    width: auto;
    max-width: var(--size-select-max);
  }

  .nav-actions > * {
    flex: 0 0 auto;
  }

  .nav-overflow {
    position: relative;
    flex: 0 0 auto;
  }

  .nav-more-btn {
    inline-size: var(--size-nav-toggle);
    block-size: var(--size-nav-toggle);
  }

  .overflow-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--header-color);
    border: var(--border);
    border-radius: var(--radius-m);
    box-shadow: var(--header-control-shadow);
    padding: var(--space-s);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    z-index: calc(var(--layer-header) + 20);
  }

  .overflow-menu a {
    display: block;
    padding: var(--space-s) var(--space-base);
    border-radius: var(--radius-s);
    white-space: nowrap;
  }

  .overflow-menu a:hover,
  .overflow-menu a:focus {
    background: var(--surface-hover-soft);
    text-decoration: none;
  }

  .footer--desktop {
    display: flex;
  }

  .footer-mobile-nav {
    display: none;
  }

  body {
    padding-bottom: 0;
  }
}

/* Wrapping safeguards */
.header-content, .nav, .nav-links, .nav-actions { min-width: 0; }
header a { white-space: nowrap; }
@media (max-width: 900px) { header a { white-space: normal; } }


/* Main */
.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#main-logo { width: 250px; height: auto; max-width: 50%; }

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

.align-right {float: right;}

/* =========================================
   Forms & Controls
   ========================================= */
form {
  margin: var(--space-xl) auto;
  padding: var(--space-base) var(--space-base);
  border: var(--border);
  border-radius: var(--radius-l);
  background-color: var(--gray-75);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-base);
  box-sizing: border-box;
  width: 100%;
  max-width: var(--content-form-max);
  font: inherit;
}

form label {
  color: var(--gray-500);
  font-size: var(--font-size-s);
}

form div.group { display: flex; flex-direction: column; gap: 0; }

label.required::after {
  content: " *";
  color: var(--error-strong);
  font-weight: bold;
}

/* Shared field chrome */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select {
  padding: var(--space-none) var(--space-base);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-m);
  box-shadow: none;
  font-size: 1rem;
  box-sizing: border-box;
  outline: none;
  transition: border var(--duration-base) var(--easing), box-shadow var(--duration-base) var(--easing);
  width: 100%;
  max-width: 50ch;
  min-width: 5ch;
  min-height: 48px;
  background-color: var(--surface-alt-strong);
  color: var(--text-default);
}

textarea {
  padding: var(--space-base) var(--space-base);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-m);
  box-shadow: none;
  background-color: var(--surface-alt-strong);
  color: var(--text-default);
  width: 100%;
  min-height: calc(1.5em * 3);  /* 3 text rows */
  max-height: calc(1.5em * 10); /* 10 text rows */
  line-height: 1.5;
  overflow-y: auto;
  box-sizing: border-box;
  resize: vertical;
}

/* Focus style (shared) */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* Select specifics */
select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: var(--select-arrow-icon);
  background-repeat: no-repeat;
  background-position: right 0.75em center;
  background-size: 1em;
  padding-right: 2.5em;
}
select:disabled {
  background-color: var(--gray-150);
  color: var(--gray-500);
  cursor: not-allowed;
}

.site-header .header-control--select select,
.site-header .header-control--select select:not([multiple]):not([size]) {
  background-image: none;
  padding-right: 0;
}


/* Buttons */
button:not(.header-control) {
  min-height: 46px;
  padding: 0 var(--space-base);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-m);
  background-color: var(--color-primary);
  color: #fff;
  cursor: pointer;
  box-shadow: none;
  transition: background-color var(--duration-base) var(--easing), box-shadow var(--duration-base) var(--easing);
  margin: var(--space-xs);
}
button:not(.header-control):hover {
  background-color: var(--color-primary-hover);
  box-shadow: none;
}
button:not(.header-control):active {
  background-color: var(--color-primary-hover);
  box-shadow: none;
}

/* =========================================
   Tables
   ========================================= */
table {
  margin-top: 32px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: var(--border);
  border-radius: var(--radius-l);
  box-shadow: none;
  font-size: 1rem;
  background: var(--gray-75);
  transition: border var(--duration-base) var(--easing), box-shadow var(--duration-base) var(--easing);
  word-break: break-word;
  overflow-wrap: anywhere;
}
table:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft-elevated), var(--focus-ring);
}
table thead th {
  color: var(--text-strong);
  background: var(--surface-alt-strong);
  text-align: left;
  font-weight: 600;
  padding: 0.75em 1em;
  border-bottom: var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
  word-break: break-word;
  overflow-wrap: anywhere;
}
table thead th.sorted { color: var(--accent); }
table thead th.sorted::after {
  content: "";
  display: inline-block;
  margin-left: 0.4em;
  width: 0; height: 0;
  border-left: var(--space-xs) solid transparent;
  border-right: var(--space-xs) solid transparent;
}
table thead th.sort-asc::after  { border-bottom: 6px solid currentColor; transform: translateY(-1px); }
table thead th.sort-desc::after { border-top: 6px solid currentColor; transform: translateY(1px); }

table td {
  padding: 0.75em 1em;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: anywhere;
}

table tbody tr:nth-child(odd) { background: var(--gray-50); }
table tbody tr:hover { background: var(--row-hover-bg); }

table thead th:first-child { border-top-left-radius: var(--radius-m); }
table thead th:last-child  { border-top-right-radius: var(--radius-m); }
table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-m); }
table tbody tr:last-child td:last-child  { border-bottom-right-radius: var(--radius-m); }

/* === Generic responsive table (stack on mobile) === */
.table--stack { width: 100%; }

@media (max-width: 768px) {
  .table--stack thead { display: none; }

  .table--stack tr {
    display: block;
    border: var(--border);
    border-radius: var(--radius-l);
    padding: var(--space-base) var(--space-base);
    margin: var(--space-base) var(--space-none);
    background: var(--gray-75);
    box-shadow: none;
  }

  .table--stack td {
    display: grid;
    grid-template-columns: 40% 1fr; /* label : value */
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border: 0;
  }

  .table--stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-700-soft);
    align-self: center;
  }

  .table--stack td.is-control,
  .table--stack td.is-actions {
    grid-template-columns: 1fr max-content; /* label left, button(s) right */
    align-items: center;
  }

  .table--stack input[type="checkbox"] {
    inline-size: var(--size-checkbox-touch);
    block-size: var(--size-checkbox-touch);
    margin: 0;
    line-height: 1;
    -webkit-appearance: checkbox; /* avoid unexpected scaling on iOS */
    appearance: checkbox;
  }
}


/* =========================================
   Messages / Alerts
   ========================================= */
.error-box,
.success-box,
.warning-box {
  padding: var(--space-base) var(--space-base);
  margin: var(--space-m) var(--space-none);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-m);
  display: none;
}

.error-box {
  background-color: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

.success-box {
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  transition: opacity 0.5s ease;
}

.warning-box {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.error {
  border: 2px solid var(--error-strong);
  background-color: var(--error-bg-soft);
}

.error-message {
  color: var(--error-strong);
  font-size: 0.9em;
  margin-top: 4px;
}

.icon-delete {
  width: 24px;
  height: 24px;
  color: var(--delete-red);
  stroke: currentColor;
  fill: none;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.launch-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-base);
  padding: var(--space-base);
}

button.launch {
  width: 100%;
  aspect-ratio: 3 / 1;

  border: var(--border);
  border-radius: var(--radius-l);
  padding: var(--space-base);

  background: var(--gray-75);
  color: var(--text-strong);

  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  transition: border-color 0.12s ease-out, background-color 0.12s ease-out;
}

button.launch:hover {
  transform: none;
  border-color: var(--color-primary);
  background: var(--gray-100);
}

/* Active / click effect */
button.launch:active {
  transform: none;
  box-shadow: none;
  background: var(--surface-alt-strong);
}

/* Optional: keyboard focus outline */
button.launch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:hover .icon-delete {
  fill: currentColor;
  stroke: var(--text-on-accent);
}

.confirm-backdrop {
  position: fixed; inset: 0; background: var(--overlay-backdrop-strong);
  backdrop-filter: blur(2px); z-index: 1000;
}
.confirm-modal {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 1001;
}
.confirm-modal[hidden], .confirm-backdrop[hidden] { display: none !important; }

.confirm-card {
  width: min(520px, 92vw);
  background: var(--gray-75);
  color: var(--gray-600);
  border: var(--border);
  border-radius: var(--radius-m);
  box-shadow: none;
  padding: var(--space-m);
  font: inherit;
}
.confirm-title {
  margin: 0 0 var(--space-s);
  font-size: var(--font-size-h5);
  color: var(--text-strong);
}
.confirm-message { margin: 0 0 var(--space-base); color: var(--text-default); }

.confirm-label {
  display: grid; gap: var(--space-xs);
  margin: var(--space-s) 0 var(--space-base);
  font-size: var(--font-size-s);
  color: var(--gray-500);
}
.confirm-input {
  padding: .6em 1em; border: 1px solid var(--gray-400);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-soft-elevated);
  font-size: 1rem; width: 5ch; text-align: center;
  background: var(--surface-base); color: inherit; outline: none;
  transition: border var(--duration-base) var(--easing),
              box-shadow var(--duration-base) var(--easing);
}
.confirm-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft-elevated), var(--focus-ring);
}

.confirm-actions { display: flex; gap: var(--space-s); justify-content: flex-end; }
.btn.btn--ghost { background: var(--gray-100); color: var(--gray-600); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }


/* =========================================
   Misc layout helpers & components
   ========================================= */
.asset-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-base); }
.assetImg { max-width: 400px; max-height: 400px; }

.help-container { position: relative; display: inline-block; }

.help-button {
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.tooltip {
  visibility: hidden;
  background-color: var(--tooltip-bg);
  color: var(--text-on-accent);
  text-align: left;
  padding: var(--space-s);
  border-radius: var(--radius-s);
  position: absolute;
  top: 40px;
  left: 0;
  width: 250px;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--duration-base) var(--easing);
}
.help-container:hover .tooltip { visibility: visible; opacity: 1; }

img.map, img.qr {max-width: var(--size-media-max); width: 100%;}

.thumbnail {
  max-width:80px;
  max-height:80px;
  object-fit:cover;
}

img.zoomable {
  cursor: pointer;
}

dialog.imgDialog {
  border: none;
  padding: 0;
  background: transparent;
}

.large-img {
  max-width: 90vw;
  max-height: 90vh;
}

dialog.imgDialog::backdrop {
  background: var(--overlay-backdrop-light);
}

#closeBtn {
  position: absolute;
  top: var(--space-s);
  right: var(--space-base);
  padding: var(--space-xs) var(--space-s);
}

div.qr { max-width: var(--size-media-max);}
div.qr > svg {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
}

/* ===== Tabs component (scoped) ===== */
.tabs {
  max-width: 100vw;
  width: 100%;
  overflow-x: hidden;
  margin: var(--space-l) auto;
  background: var(--gray-75);
  border: var(--border);
  border-radius: var(--radius-m);
  box-shadow: none;
  overflow: hidden;
  font: inherit;
}
.tabs .tablist {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scroll-snap-type: x mandatory;
  scroll-snap-align: start;
  contain: content;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: var(--gray-100);
  border-bottom: var(--border);
  mask-image: linear-gradient(to right, transparent 0, var(--surface-alt) var(--space-base),  var(--surface-alt) calc(100% - var(--space-base)), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, var(--surface-alt) var(--space-base),  var(--surface-alt) calc(100% - var(--space-base)), transparent 100%);
}

.tabs .tab {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 0;
  appearance: none;
  border: 0;
  background: transparent;
  padding: calc(var(--space-s) * 0.75) var(--space-base);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--font-size-l);
  color: var(--color-primary);
  cursor: pointer;
  outline: none;
  transition: background-color var(--duration-fast) var(--easing), color var(--duration-fast) var(--easing), box-shadow var(--duration-fast) var(--easing);
}
.tabs .tab:hover {
  background: var(--surface-hover-soft);
  color: var(--color-primary-hover);
}
.tabs .tab[aria-selected="true"] {
  background: var(--color-secondary);
  color: var(--text-strong);
  box-shadow: var(--shadow-xs);
}
.tabs .tab:focus-visible { box-shadow: var(--focus-ring); }

.tabs .tabpanel {
  padding: var(--space-base) var(--space-l) var(--space-l);
  display: none;
  animation: tabs-fade var(--duration-fast) var(--easing);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  background: var(--gray-75);
  max-width: 100%;
  overflow-x: hidden;
}

.tabs .tabpanel[data-active] { display: block; }

@keyframes tabs-fade { from { opacity: 0 } to { opacity: 1 } }

/* No-JS fallback */
.no-js .tabs .tabpanel { display: block; }

/* === Asset table === */
.asset-filters {
  display:flex;
  gap:.5rem;
  align-items:center;
  flex-wrap:wrap;
  margin-bottom:.5rem;
  border: var(--border-subtle);
  border-radius: var(--radius-m);
  padding:.5rem .75rem .75rem;
  min-inline-size: min(100%, 820px);
}
.asset-filters__legend {
  font-weight: 600;
  color: var(--text-subtle-strong);
  font-size: var(--font-size-s);
  padding: 0 .35em;
}
.asset-filters input, .asset-filters select { padding:.4rem .6rem; }
.asset-filters button { padding:.4rem .6rem; }

.mobile-sort { display: none; align-items: center; gap: .5rem; }
.mobile-sort-label {
  font-weight: 600;
  color: var(--text-subtle-strong);
}

.asset-totals {
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:.5rem;
  margin-top:.5rem;
  padding:.5rem;
  border-top: var(--border);
}

.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.assets {
  max-width: var(--content-form-max);
  border-collapse: collapse;
}

.assets thead th {
    cursor: pointer;
}

.assets th, .assets td {
  padding: var(--space-base);
  border-bottom: var(--border-subtle);
  text-align: left;
}
.assets th { font-weight: 600; }

.assets th.select-col, .assets td.select-col { width: 2.5rem; text-align: center; }
.assets td.select-col input[type="checkbox"] { transform: translateY(1px); }
/* Ensure header sort styles ignore the first column */
.assets thead th.select-col { cursor: default !important; }

.asset-bulkbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: none;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  background: var(--bulkbar-bg);
  border: 1px solid var(--bulkbar-border);
  border-radius: .5rem;
  padding: .5rem .75rem;
  margin-top: .75rem;
  box-shadow: var(--shadow-sticky);
}
.asset-bulkbar--visible { display: flex; }
.asset-bulkbar__left { display: flex; gap: .5rem; align-items: center; }
.asset-bulkbar__right { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.asset-bulkbar button, .asset-bulkbar select {
  font: inherit;
}

@media (max-width: 768px) {
  .asset-filters {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }

  .assets.table--stack td.select-col {
    /* no label column for the checkbox cell */
    grid-template-columns: max-content;  /* just the checkbox */
    align-items: center;
  }
  .assets.table--stack td.select-col::before {
    content: none !important;            /* hide "Valitse" label */
  }
  .assets.table--stack td.select-col input[type="checkbox"] {
    width: var(--size-checkbox-touch);
    height: var(--size-checkbox-touch);
    margin: 0;
    justify-self: start;
  }

  .mobile-sort { display:flex; margin:0.5rem 0; }

  .assets td.select-col {
    display: flex;             /* instead of grid */
    align-items: center;
    justify-content: flex-start;
    padding: 8px 0;            /* keep it compact */
    border: 0;
  }
  .assets td.select-col::before {
    content: none !important;  /* hide "Valitse" label */
  }

  /* Make the touch target comfy on mobile */
  .assets td.select-col input[type="checkbox"] {
    width: var(--size-checkbox-touch);
    height: var(--size-checkbox-touch);
    transform: none;
  }

  .asset-bulkbar { position: fixed; left: .75rem; right: .75rem; bottom: .75rem; }

  .asset-totals { grid-template-columns: 1fr; }

  /* Optional: hide least-important columns on tiny screens
     .assets td:nth-child(2) { display: none; }
  */
}

/* Ensure [hidden] truly hides */
.assets tr[hidden], [hidden] { display: none !important; }


/* ===== Messages module (leans on your tokens) ===== */
.messages.module.card {
  background: var(--gray-75);
  border: var(--border);
  border-radius: var(--radius-l);
  box-shadow: none;
  margin: var(--space-l) auto;
  max-width: 100%;
  overflow-x: hidden;
}

.messages__layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 0;
  min-height: 560px;
  max-width: 100%;
  overflow: hidden;
}

.messages__sidebar {
  border-right: var(--border-subtle);
  background: var(--gray-75);
  display: flex;
  flex-direction: column;
}
.messages__sidebar-header { padding: var(--space-base) var(--space-base) var(--space-s); }
.messages__title { margin: 0; font-size: var(--font-size-h5); color: var(--gray-600); }

.conversation-list {
  list-style: none; margin: 0; padding: 0;
  overflow: auto; height: 100%;
}
.conversation-item { border-bottom: var(--border-subtle); }
.conversation-item__btn {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  padding: var(--space-base);
  display: grid;
  grid-template-columns: var(--size-avatar) 1fr;
  gap: var(--space-base);
  cursor: pointer;
  font: inherit;
}
.conversation-item__btn:hover { background: var(--gray-100); }
.conversation-item__btn[aria-current="true"] {
  background: var(--row-hover-bg);
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
  display: grid;
  grid-template-columns: var(--size-avatar) minmax(0, 1fr);
}

.conversation-item__avatar {
  inline-size: var(--size-avatar);
  block-size: var(--size-avatar);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gray-200); color: var(--gray-600);
  font-weight: 700;
}
.conversation-item__meta {
  display: grid;
  gap: var(--space-xs);
  align-content: center;
  min-width: 0;
}
.conversation-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  min-width: 0;
  flex-wrap: nowrap;
}

.conversation-item__name { font-weight: 600; color: var(--text-strong); }

.conversation-item__time {
  flex: 0 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-xs);
  color: var(--gray-600);
}

.conversation-item__snippet {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
  font-size: var(--font-size-s);
  color: var(--text-default);
}

.badge.badge--unread {
  flex: 0 0 auto;
  background: var(--state-sale-color);
  color: var(--text-on-accent);
  border-radius: var(--radius-pill);
  padding: 0 .5em;
  font-size: var(--font-size-xs);
  line-height: 1.6;
  margin-left: var(--space-s);
}

/* Main chat area */
.messages__main {
  position: relative;
  background: var(--gray-75);
  max-width: 100%;
  overflow-x: hidden;
  max-inline-size: 100%;
  min-inline-size: 0;
}

.chat-panel {
  display: none;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  max-inline-size: 100%;
  min-inline-size: 0;
}

.chat-panel[data-active] {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
}

.chat-panel__header {
  padding: var(--space-base) var(--space-l) var(--space-s);
  border-bottom: var(--border-subtle);
  z-index: calc(var(--layer-header) - 10);
}
.chat-panel__title { margin: 0; font-size: var(--font-size-h5); }

.chat-timeline {
  list-style: none;
  margin: 0;
  padding: var(--space-base) var(--space-l);
  overflow: auto; background: var(--gray-50);
  flex: 1 1 auto;
  overflow-y: auto;
  max-width: 100%;
  overflow-x: hidden;
  max-inline-size: 100%;
  min-inline-size: 0;
}
.chat-msg {
  display: flex;
  margin: var(--space-s) 0;
  max-inline-size: 100%;
  min-inline-size: 0;
}
.chat-msg--me { justify-content: flex-end; }
.chat-msg__bubble {
  max-width: 70%;
  background: var(--gray-75);
  border: var(--border);
  border-radius: var(--space-base);
  box-shadow: none;
  padding: var(--space-base);
  max-inline-size: 100%;
  min-inline-size: 0;
}
.chat-msg--me .chat-msg__bubble {
  background: var(--chat-me-bg);
  border-color: var(--chat-me-border);
}

.chat-msg__text {
  margin: 0 0 var(--space-xs);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-inline-size: 100%;
  min-inline-size: 0;
}

.chat-msg__meta {
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  display: flex;
  gap: var(--space-s);
  justify-content: flex-end;
}

/* Reply box (compact form variant) */
.form--compact {
  margin: 0;
  border: var(--border-subtle);
  border-radius: 0;
  background: var(--gray-100);
  box-shadow: none;
  padding: var(--space-s) var(--space-l);
}
.chat-reply {
  border-top: var(--border-subtle);
  position: sticky;
  bottom: 0;
  background: var(--surface-base);
  padding: var(--space-s);
  z-index: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.chat-reply__send {
  flex: 0 0 auto;
  max-width: 45%;
  white-space: nowrap;
}

.chat-reply__row {
  display: flex;
  gap: var(--space-s);
  align-items: flex-end;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  flex-wrap: nowrap;
}
.chat-reply__input {
  flex: 1 1 0%;
  width: 100%;
  resize: vertical;
  max-height: 40vh;
  min-height: 44px;
  min-width: 0;
  min-inline-size: 0;
  max-inline-size: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: .6em 1em;
  border: 1px solid var(--gray-400);
  border-radius: var(--radius-m);
  box-sizing: border-box;
  box-shadow: var(--shadow-soft-elevated);
  background: var(--surface-base);
  font: inherit;
  outline: none;
}
.chat-reply__input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft-elevated), var(--focus-ring);
}

/* Empty */
.messages__empty { padding: var(--space-l); color: var(--gray-600); }

.message-dialog {
  border: none;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-l);
  padding: 0;
  width: min(400px, 90vw);
}

.message-dialog::backdrop {
  background: var(--overlay-backdrop-medium);
  backdrop-filter: blur(2px);
}

.message-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-s) var(--space-base);
  border-bottom: var(--border-subtle);
}

.message-dialog__body {
  padding: var(--space-base);
}

.message-dialog__inner textarea {
  width: 100%;
  resize: vertical;
  border: var(--border);
  border-radius: var(--radius-m);
  padding: .6em 1em;
  font: inherit;
  min-height: 80px;
  box-sizing: border-box;
}

.message-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-s);
  margin-top: var(--space-s);
}

.message-dialog__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}





/* Uploader */

.uploader {
  --radius: var(--radius-m);
  --pad: var(--space-l);
  --pad-s: var(--space-base);
  --accent: var(--state-sale-color);
  font-family: var(--font-family-base);
  max-width: 560px;
  margin: var(--space-l) 0;
}
.uploader__dropzone {
  background: var(--gray-75);
  border: 2px dashed var(--color-secondary);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: none;
  color: var(--color-primary);
  display: grid; gap: var(--space-base); justify-items: center; text-align: center;
  transition: border-color .2s, box-shadow .2s, color .2s;
  outline: none;
}
.uploader__dropzone:hover,
.uploader__dropzone:focus,
.uploader__dropzone.is-dragover {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft-elevated), var(--focus-ring);
  color: var(--color-primary-hover);
}
.uploader__icon { color: var(--color-secondary); }
.uploader__title { font-size: var(--font-size-h5); font-weight: 600; }
.uploader__subtitle { font-size: var(--font-size-s); opacity: .8; }
.uploader__hint {
  font-size: var(--font-size-xs);
  color: var(--color-secondary);
  margin-top: var(--space-base);
}
.uploader__actions { display: inline-flex; gap: var(--space-base); }

.btn--ghost {
  background: var(--surface-base);
  color: var(--color-primary);
  border: var(--border-soft);
  box-shadow: var(--shadow-soft-elevated);
}
.btn--ghost:hover {
  background: var(--surface-base);
  color: var(--color-primary-hover);
  box-shadow: var(--shadow-m);
}

.uploader__preview,
.uploader__fields {
  margin-top: var(--space-base);
  display: grid;
  gap: var(--space-base);
  background: var(--gray-75);
  border: var(--border-soft);
  border-radius: var(--radius-m);
  padding: var(--space-base);
  box-shadow: none;
}
.uploader__preview img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-m);
  display:block;
}
.uploader__preview iframe {
  width:100%;
  height:auto;
  border:0;
}
.uploader__meta {
  display:flex;
  justify-content:space-between;
  font-size: var(--font-size-xs);
  color: var(--gray-600);
}

.uploader__field { display: grid; gap: 6px; }
.uploader__label { font-size: var(--font-size-xs); color: var(--gray-600); }
.uploader__submit { display:flex; gap: var(--space-base); }

.uploader__progress-wrap {
  display:grid; grid-template-columns: 1fr auto; align-items:center; gap: var(--space-base);
  margin-top: var(--space-base);
}

.uploader__progress-wrap.is-indeterminate .uploader__bar {
  transition: width 0.15s linear; /* the JS timer advances width */
}

.uploader__progress {
  height: var(--space-s);
  background: var(--progress-bg);
  border: 1px solid var(--gray-300);
  border-radius:999px;
  overflow:hidden;
}
.uploader__bar {
  height: 100%;
  background: var(--progress-fill);
  width:0%;
  transition: width .15s linear;
}

.uploader__percent {
  min-width:3ch;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
  font-size: var(--font-size-s);
}

.uploader__progress-actions { grid-column: 1 / -1; display:flex; gap: var(--space-base); }

@media (max-width: 480px) {
  .uploader { margin: var(--space-base); }
  .uploader__actions, .uploader__submit { flex-direction: column; }
  .uploader__actions > *, .uploader__submit > * { width: 100%; }
}
.uploader [hidden] { display: none !important; }



/* Responsive */
@media (max-width: 768px) {
  .conversation-item__row { flex-wrap: wrap; }
  .conversation-item__snippet {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .messages__layout { grid-template-columns: 1fr; }
  .messages__sidebar { order: 2; }
  .messages__main { order: 1; }
  .chat-msg__bubble { max-width: 88%; }
}


@media print {
  /* Hide everything by default (keeps layout for the shown element) */
  body * { visibility: hidden !important; }

  /* Show the target and its descendants */
  .print-target, .print-target * { visibility: visible !important; }

  /* Lift it to the page origin so it uses the paper cleanly */
  .print-target {
    position: absolute;
    left: 0; top: 0;
    right: 0; /* allow full width */
    margin: 0;
    width: 100%;
    height: auto;
    display: block;
  }
}