/* ==========================================================================
   Helpdesk — modern responsive theme
   File: /home/decosun/decosun.ua/helpdesk/public/style.css
   ========================================================================== */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --primary: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 10px 30px rgba(2, 6, 23, .08), 0 2px 8px rgba(2, 6, 23, .05);
  --shadow-soft: 0 6px 18px rgba(2, 6, 23, .06);
  --radius: 16px;
  --radius-sm: 12px;
  --ring: 0 0 0 3px rgba(14, 165, 233, .25);
  --header-bg: rgba(15, 23, 42, .96);
  --header-bg-2: rgba(15, 23, 42, .86);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* DARK (forced via JS toggle) */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #0f172a;
  --surface-2: #111c30;
  --surface-3: #17233a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
  --border-strong: #334155;
  --primary: #38bdf8;
  --primary-600: #0ea5e9;
  --primary-700: #0284c7;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, .22);
}

/* LIGHT (forced via JS toggle) */
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --primary: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 10px 30px rgba(2, 6, 23, .08), 0 2px 8px rgba(2, 6, 23, .05);
  --shadow-soft: 0 6px 18px rgba(2, 6, 23, .06);
}

/* Auto dark mode (when no explicit data-theme set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0b1220;
    --surface: #0f172a;
    --surface-2: #111c30;
    --surface-3: #17233a;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #1f2937;
    --border-strong: #334155;
    --primary: #38bdf8;
    --primary-600: #0ea5e9;
    --primary-700: #0284c7;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, .22);
  }
}

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

html {
  height: 100%;
  min-width: 0;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  font: 14px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -20%, rgba(56, 189, 248, .10), transparent 60%),
    radial-gradient(900px 500px at -10% -10%, rgba(16, 185, 129, .08), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.nav-open {
  overflow: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
summary,
label,
select,
input[type="checkbox"],
input[type="radio"] {
  touch-action: manipulation;
}

::selection {
  background: rgba(14, 165, 233, .22);
}

/* Links */
a {
  color: var(--primary-600);
  text-decoration: none;
}

a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

/* Headings */
h1,
h2,
h3,
h4 {
  margin: 0 0 .5rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 800;
  letter-spacing: -.02em;
}

h2 {
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 700;
}

h3 {
  font-size: clamp(16px, 1.4vw, 20px);
  font-weight: 700;
  opacity: .95;
}

p {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

small {
  color: var(--muted);
}

/* ---------- Layout ---------- */
.container {
  width: 98vw;
  max-width: none;
  padding: 24px 0;
  margin: 0 auto;
  min-width: 0;
}

.card {
  width: 100%;
}

main,
section,
article,
aside,
header,
footer,
nav,
.card,
.row,
.col {
  min-width: 0;
}

/* ---------- Header / Navigation ---------- */
.topbar,
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--header-bg), var(--header-bg-2));
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-header-top {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

.topbar .brand a,
.site-header .brand {
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .2px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar .brand a::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--primary) 0%, #22c55e 100%);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .25);
  display: inline-block;
  flex: 0 0 auto;
}

.site-header .brand .brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--primary) 0%, #22c55e 100%);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .25);
  display: inline-block;
  flex: 0 0 auto;
}

.site-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.site-header-right .btn {
  min-height: 40px;
}

.site-header-right .btn.ghost,
.icon-btn,
.nav-link,
.site-header .topnav > a,
.nav-group > summary {
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .04);
}

.site-header-right .btn.ghost:hover,
.icon-btn:hover,
.nav-link:hover,
.site-header .topnav > a:hover,
.nav-group > summary:hover {
  color: #fff;
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .16);
  text-decoration: none;
}

.site-header .topnav {
  width: 100%;
  max-width: 1400px;
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.nav-link,
.site-header .topnav > a,
.nav-group > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .08s ease;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  user-select: none;
}

.nav-link:active,
.site-header .topnav > a:active,
.nav-group > summary:active {
  transform: translateY(1px);
}

.nav-link.active,
.site-header .topnav > a.active,
.nav-group.is-current > summary,
.nav-group[open] > summary {
  background: rgba(56, 189, 248, .16);
  color: #fff;
  border-color: rgba(56, 189, 248, .28);
}

.logout-link {
  margin-left: auto;
}

.nav-group {
  position: relative;
  min-width: 0;
}

.nav-group summary {
  list-style: none;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group .caret {
  width: 16px;
  height: 16px;
  opacity: .85;
  transition: transform .2s ease;
  flex: 0 0 auto;
}

.nav-group[open] .caret {
  transform: rotate(180deg);
}

.nav-submenu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 40;
  min-width: 240px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(15, 23, 42, .98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .25);
  display: none;
  grid-template-columns: 1fr;
  gap: 6px;
}

.nav-group[open] > .nav-submenu {
  display: grid;
}

.nav-submenu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  color: #e5e7eb;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.nav-submenu a:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .10);
  text-decoration: none;
}

.nav-submenu a.active {
  background: rgba(56, 189, 248, .16);
  color: #fff;
  border-color: rgba(56, 189, 248, .28);
}

.nav-toggle {
  display: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  cursor: pointer;
  border-style: solid;
}

.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

.icon-btn.is-dark .icon-sun {
  display: block;
}

.icon-btn.is-dark .icon-moon {
  display: none;
}

@media (hover: hover) and (min-width: 861px) {
  .nav-group:hover > .nav-submenu {
    display: grid;
  }

  .nav-group:hover > summary {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-color: rgba(255, 255, 255, .16);
  }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 18px 0;
  box-shadow: var(--shadow);
  min-width: 0;
}

/* ---------- Grid helpers ---------- */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  min-width: 0;
}

.col {
  flex: 1 1 260px;
  min-width: 220px;
}

/* ---------- Forms ---------- */
label {
  display: block;
  margin: 6px 0 6px;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
  overflow-wrap: anywhere;
}

input[type="file"] {
  width: 100%;
  max-width: 100%;
  color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:invalid,
textarea:invalid,
select:invalid {
  border-color: #fca5a5;
}

input:disabled,
textarea:disabled,
select:disabled,
button:disabled {
  opacity: .7;
  cursor: not-allowed;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .2px;
  box-shadow: 0 6px 18px rgba(14, 165, 233, .25);
  transition: transform .08s ease, background .15s ease, box-shadow .2s ease, border-color .15s ease, color .15s ease;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  color: #fff;
  background: var(--primary-600);
  box-shadow: 0 10px 24px rgba(14, 165, 233, .35);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn.secondary {
  background: #334155;
  box-shadow: none;
  color: #fff;
}

.btn.secondary:hover {
  background: #1f2937;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Small button variant when inside tables */
.table .btn,
.table .btn.secondary,
.table .btn.ghost {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 600;
}

/* ---------- Tables ---------- */
.card .table-wrapper,
.table-wrapper,
.scroll-x {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-radius: 12px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  min-width: 720px;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.table tbody tr:hover {
  background: rgba(2, 6, 23, .03);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="light"] .table tbody tr:hover {
    background: rgba(2, 6, 23, .03);
  }

  :root:not([data-theme="light"]) .table tbody tr:hover {
    background: rgba(255, 255, 255, .03);
  }
}

.table td:first-child a {
  white-space: nowrap;
}

@media (min-width: 960px) {
  .table th:nth-child(1),
  .table td:nth-child(1) {
    width: 110px;
  }

  .table th:nth-child(7),
  .table td:nth-child(7) {
    width: 160px;
  }

  .table th:nth-child(8),
  .table td:nth-child(8) {
    width: 120px;
  }

  .table th:nth-child(9),
  .table td:nth-child(9) {
    width: 90px;
  }

  .table th:last-child,
  .table td:last-child {
    width: 160px;
  }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.15;
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .15);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge.ok {
  background: var(--success);
}

.badge.warn {
  background: var(--warning);
}

.badge.danger {
  background: var(--danger);
}

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

/* ---------- Unified task statuses / priorities ---------- */
.status-badge,
.priority-badge {
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .01em;
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, .18),
    0 4px 12px rgba(15, 23, 42, .08);
}

.hd-status-select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 8px 34px 8px 10px;
  border: 1px solid var(--status-border, var(--border));
  border-radius: 10px;
  background-color: var(--status-bg, var(--surface-2));
  color: var(--status-fg, var(--text));
  font-weight: 850;
  line-height: 1.2;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .10) inset,
    0 4px 12px rgba(15, 23, 42, .08);
  cursor: pointer;
}

.hd-status-select:hover {
  filter: brightness(1.02);
}

.hd-status-select:focus {
  border-color: var(--status-border, var(--primary));
  background-color: var(--status-bg, var(--surface));
  color: var(--status-fg, var(--text));
  box-shadow:
    0 0 0 3px rgba(14, 165, 233, .22),
    0 0 0 1px rgba(255, 255, 255, .12) inset;
}

.hd-status-select option {
  font-weight: 750;
}

:root[data-theme="dark"] .status-badge,
:root[data-theme="dark"] .priority-badge {
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, .14),
    0 4px 12px rgba(0, 0, 0, .18);
}

:root[data-theme="dark"] .hd-status-select {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .08) inset,
    0 4px 12px rgba(0, 0, 0, .18);
}

/* ---------- Flash ---------- */
.flash {
  background: linear-gradient(180deg, #111827, #0b1220);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 16px 0;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

/* ---------- Footer ---------- */
.footer,
.site-footer {
  width: 100%;
  max-width: 1400px;
  padding: 28px 18px 40px;
  margin: 0 auto;
  color: var(--muted);
  text-align: left;
}

/* ---------- Content styling ---------- */
.card hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.card img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.card blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--surface-2);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.card code,
.card pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.card pre {
  padding: 10px 12px;
  overflow: auto;
  max-width: 100%;
}

/* ---------- Forms layout niceties ---------- */
form .row {
  align-items: flex-end;
}

form .row > .col {
  min-width: min(100%, 320px);
}

/* ---------- Utilities ---------- */
.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.shadow-sm {
  box-shadow: 0 2px 10px rgba(2, 6, 23, .05);
}

.shadow {
  box-shadow: var(--shadow);
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.flash {
  animation: fadeInUp .25s ease both;
}

/* ---------- Tiny MCE content ---------- */
.card .mce-content-body,
.card .tinymce-output {
  line-height: 1.7;
  letter-spacing: .01em;
  overflow-wrap: anywhere;
}

.tox-tinymce {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
  max-width: 100%;
}

/* ==========================================================================
   Home dashboard
   ========================================================================== */

.home-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 18px;
  align-items: start;
}

.home-clock {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-clock-time {
  margin: 0 0 8px 0;
  font-size: 46px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.03em;
}

.home-clock-date {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.home-title {
  margin: 0 0 8px 0;
}

.home-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.home-filters {
  min-width: 0;
}

.home-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.home-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, .01));
  transition: border-color .15s ease, background .15s ease, transform .08s ease, box-shadow .15s ease;
  min-width: 0;
}

.home-item:hover {
  background: var(--surface);
  border-color: rgba(14, 165, 233, .26);
  box-shadow: var(--shadow-soft);
}

.home-task-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.home-task-main {
  min-width: 0;
  flex: 1 1 auto;
}

.home-task-link {
  display: inline-block;
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.home-task-link:hover {
  color: var(--primary-600);
  text-decoration: none;
}

.home-item-strong {
  font-weight: 800;
  color: var(--text);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.home-task-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 0;
}

.home-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  min-width: 0;
}

.home-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .10);
  border: 1px solid rgba(148, 163, 184, .18);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.home-item-flag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.home-item-flag.overdue {
  color: #fecaca;
  background: rgba(239, 68, 68, .14);
  border: 1px solid rgba(239, 68, 68, .24);
}

.home-item-flag.today {
  color: #bfdbfe;
  background: rgba(59, 130, 246, .14);
  border: 1px solid rgba(59, 130, 246, .24);
}

.home-task-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.home-status-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  justify-content: flex-end;
  min-width: 0;
}

.home-status-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.home-status-select {
  min-width: 220px;
  max-width: 260px;
  width: auto;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  white-space: nowrap;
  color: var(--text);
}

.home-empty {
  color: var(--muted);
  padding: 10px 0;
}

.home-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  min-width: 0;
}

.home-section-head h3 {
  margin: 0;
}

/* ==========================================================================
   Tasks page
   ========================================================================== */

.tasks-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}

.tasks-title {
  margin: 0;
}

.tasks-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.tasks-counter {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .10);
  border: 1px solid rgba(148, 163, 184, .18);
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.tasks-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  margin-top: 16px;
  min-width: 0;
}

.tasks-field {
  min-width: 0;
}

.tasks-field-check label:first-child {
  visibility: hidden;
}

.tasks-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
}

.tasks-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}

.tasks-filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.task-card {
  margin: 0;
  min-width: 0;
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.task-card-main {
  min-width: 0;
  flex: 1 1 auto;
}

.task-card-link {
  display: inline-block;
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-card-link:hover {
  color: var(--primary-600);
  text-decoration: none;
}

.task-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex: 0 0 auto;
  max-width: 42%;
  min-width: 0;
}

.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  min-width: 0;
}

.task-meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .10);
  border: 1px solid rgba(148, 163, 184, .18);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.task-card-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.task-status-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.task-status-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-status-select {
  min-width: 220px;
  max-width: 260px;
  width: auto;
}

.task-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Generic task/view content safety */
.task-view,
.task-view-grid,
.task-details,
.task-comments,
.task-history,
.task-attachments {
  min-width: 0;
  max-width: 100%;
}

.task-description,
.task-comment,
.comment,
.comment-body,
.attachment-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ==========================================================================
   Vault (Passwords) — UX layout
   ========================================================================== */

.vault-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.vault-card {
  margin: 0;
}

.vault-sidebar .vault-card {
  position: sticky;
  top: 84px;
}

.vault-main .vault-card {
  margin-bottom: 18px;
}

.vault-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.vault-side-title {
  font-weight: 900;
  letter-spacing: .01em;
  font-size: 14px;
}

.vault-btn-sm {
  padding: 7px 10px;
  border-radius: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.vault-folderlist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  min-width: 0;
}

.vault-folder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.vault-folder:hover {
  background: var(--surface);
  text-decoration: none;
}

.vault-folder.active {
  border-color: rgba(14, 165, 233, .45);
  box-shadow: 0 10px 24px rgba(14, 165, 233, .10);
}

.vault-folder .name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.vault-folder .count {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .18);
  border: 1px solid rgba(148, 163, 184, .28);
  color: var(--muted);
  flex: 0 0 auto;
}

.vault-details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.vault-summary {
  cursor: pointer;
  list-style: none;
  font-weight: 900;
  user-select: none;
}

.vault-summary::-webkit-details-marker {
  display: none;
}

.vault-summary:before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transform: translateY(-1px);
}

details[open] > .vault-summary:before {
  content: "▾";
}

.vault-label {
  display: block;
  margin: 8px 0 6px;
  font-weight: 800;
}

.vault-inlineform {
  margin-top: 10px;
}

.vault-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.vault-inline > input,
.vault-inline > select {
  flex: 1 1 240px;
  min-width: 220px;
}

.vault-inline > .btn {
  flex: 0 0 auto;
}

.vault-folder-admin {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.vault-folder-row {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}

.vault-folder-row-title {
  font-weight: 900;
  overflow-wrap: anywhere;
}

.vault-folder-row-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.vault-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}

.vault-title {
  font-size: 18px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.vault-sub {
  font-size: 13px;
  margin-top: 2px;
}

.vault-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
  min-width: 0;
}

.vault-filters input[type="text"] {
  min-width: 320px;
}

.vault-filters select {
  min-width: 260px;
}

.vault-reveal {
  margin-top: 14px;
  border: 1px solid rgba(14, 165, 233, .25);
  background: linear-gradient(180deg, rgba(56, 189, 248, .06), transparent 70%);
  border-radius: 16px;
  padding: 14px;
  min-width: 0;
}

.vault-reveal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.vault-reveal-title {
  font-weight: 900;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.vault-reveal-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.vault-field {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}

.vault-field.full {
  grid-column: 1 / -1;
}

.vault-field .label {
  font-weight: 800;
  font-size: 12px;
}

.vault-field .value {
  margin-top: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.vault-field code {
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.vault-history {
  margin: 10px 0 0 0;
  padding-left: 18px;
}

.vault-history li {
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.vault-editor {
  margin-top: 12px;
}

.vault-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  min-width: 0;
}

.vault-cell {
  min-width: 0;
}

.vault-cell.full {
  grid-column: 1 / -1;
}

.vault-editor-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.vault-share {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  min-width: 0;
}

.vault-chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, .28);
  background: rgba(148, 163, 184, .14);
  cursor: pointer;
  user-select: none;
  max-width: 100%;
}

.vault-chip input {
  margin: 0;
  flex: 0 0 auto;
}

.vault-chip span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.vault-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.vault-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 16px;
  padding: 14px;
  min-width: 0;
}

.vault-item:hover {
  background: var(--surface);
}

.vault-item-main {
  flex: 1 1 520px;
  min-width: 260px;
}

.vault-item-title {
  font-weight: 900;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}

.vault-pill {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(14, 165, 233, .28);
  background: rgba(14, 165, 233, .12);
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.vault-item-meta {
  margin-top: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.vault-item-sub {
  margin-top: 4px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.vault-actions {
  flex: 0 1 auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.vault-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Calendar / FullCalendar safety
   ========================================================================== */

.fc {
  max-width: 100%;
}

.fc .fc-toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.fc .fc-toolbar-title {
  font-size: clamp(18px, 3vw, 24px);
}

.fc .fc-button {
  border-radius: 10px !important;
  border: 1px solid var(--border) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.fc .fc-event {
  border-radius: 8px;
  padding: 2px 4px;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Printers / network / admin generic lists
   ========================================================================== */

.actions,
.form-actions,
.inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.admin-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  min-width: 0;
}

/* ---------- In-app notifications (toasts) ---------- */
.hd-toast-wrap {
  position: fixed;
  right: 14px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}

.hd-toast {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: linear-gradient(180deg, rgba(15, 23, 42, .96), rgba(11, 18, 32, .92));
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  animation: hdToastIn .18s ease-out both;
  min-width: 0;
}

.hd-toast.light {
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(248, 250, 252, .92));
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hd-toast .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .22);
  margin-top: 5px;
  flex: 0 0 auto;
}

.hd-toast .content {
  flex: 1 1 auto;
  min-width: 0;
}

.hd-toast .title {
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hd-toast .body {
  font-size: 12px;
  opacity: .92;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.hd-toast .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.hd-toast .xbtn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .08);
  color: inherit;
  cursor: pointer;
}

.hd-toast.light .xbtn {
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.hd-toast .xbtn:hover {
  background: rgba(255, 255, 255, .14);
}

.hd-toast.light .xbtn:hover {
  background: var(--surface);
}

@keyframes hdToastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hdToastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ==========================================================================
   Responsive — tablets
   ========================================================================== */

@media (max-width: 1200px) {
  .admin-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .vault-layout {
    grid-template-columns: 1fr;
  }

  .vault-sidebar .vault-card {
    position: static;
    top: auto;
  }

  .vault-filters input[type="text"] {
    min-width: 240px;
    width: 100%;
  }

  .vault-filters select {
    min-width: 220px;
    width: 100%;
  }

  .vault-grid {
    grid-template-columns: 1fr 1fr;
  }

  .vault-reveal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .container {
    padding: 22px 16px;
  }

  .table th,
  .table td {
    padding: 10px 8px;
  }

  .home-top {
    grid-template-columns: 1fr;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .tasks-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
   Responsive — mobile navigation
   ========================================================================== */

@media (max-width: 860px) {
  .site-header,
  .topbar {
    padding: 12px 14px;
  }

  .site-header-top {
    align-items: center;
  }

  .site-header .brand {
    max-width: calc(100vw - 170px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-header-right {
    gap: 8px;
  }

  .site-header-right .btn {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-header .topnav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    max-height: calc(100vh - 86px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .site-header .topnav.is-open {
    display: flex;
  }

  .logout-link {
    margin-left: 0;
  }

  .nav-link,
  .site-header .topnav > a,
  .nav-group,
  .nav-group > summary {
    width: 100%;
  }

  .nav-link,
  .site-header .topnav > a,
  .nav-group > summary {
    justify-content: space-between;
    min-height: 44px;
    white-space: normal;
    text-align: left;
  }

  .nav-submenu {
    position: static;
    top: auto;
    left: auto;
    min-width: 0;
    margin-top: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, .05);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, .08);
  }

  .nav-submenu a {
    min-height: 42px;
    white-space: normal;
  }
}

/* ==========================================================================
   Responsive — phones
   ========================================================================== */

@media (max-width: 720px) {
  body {
    font-size: 14px;
    line-height: 1.55;
  }

  .container {
    padding: 16px 12px;
  }

  .card {
    padding: 14px;
    margin: 12px 0;
    border-radius: 14px;
  }

  .btn {
    min-height: 44px;
    padding: 10px 12px;
    white-space: normal;
    text-align: center;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
    border-radius: 12px;
  }

  textarea {
    min-height: 140px;
  }

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

  .home-actions .btn,
  .home-actions .btn.ghost {
    width: 100%;
  }

  .home-clock-time {
    font-size: 38px;
  }

  .home-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .home-section-head .btn {
    width: 100%;
  }

  .home-filters {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: stretch !important;
  }

  .home-filters > div {
    width: 100%;
    min-width: 0;
  }

  .home-filters .home-status-select,
  .home-filters input[type="date"],
  .home-filters select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .home-filters .btn,
  .home-filters .btn.ghost {
    flex: 1 1 0;
    min-width: 0;
  }

  .home-task-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .home-task-link {
    font-size: 16px;
  }

  .home-task-badges {
    justify-content: flex-start;
    width: 100%;
  }

  .home-task-badges .badge,
  .home-badge {
    max-width: 100%;
  }

  .home-task-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .home-meta-pill,
  .home-item-flag {
    width: 100%;
    border-radius: 12px;
    justify-content: flex-start;
    white-space: normal;
  }

  .home-status-form {
    justify-content: flex-start;
    align-items: stretch;
  }

  .home-status-label {
    width: 100%;
  }

  .home-status-select {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .tasks-head {
    flex-direction: column;
    align-items: stretch;
  }

  .tasks-head-actions {
    width: 100%;
    align-items: stretch;
  }

  .tasks-head-actions .btn,
  .tasks-head-actions .btn.ghost,
  .tasks-counter {
    width: 100%;
  }

  .tasks-filters {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .tasks-field-check label:first-child {
    display: none;
  }

  .tasks-check {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 12px;
  }

  .tasks-filter-actions {
    width: 100%;
    align-items: stretch;
  }

  .tasks-filter-actions .btn,
  .tasks-filter-actions .btn.ghost {
    flex: 1 1 0;
    min-width: 0;
  }

  .tasks-list {
    gap: 12px;
  }

  .task-card {
    padding: 14px;
  }

  .task-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .task-card-link {
    font-size: 16px;
  }

  .task-card-badges {
    justify-content: flex-start;
    width: 100%;
    max-width: none;
  }

  .task-card-badges .badge {
    max-width: 100%;
  }

  .task-card-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 12px;
  }

  .task-meta-pill {
    width: 100%;
    border-radius: 12px;
    white-space: normal;
    justify-content: flex-start;
  }

  .task-card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .task-status-form {
    width: 100%;
    align-items: stretch;
  }

  .task-status-label {
    width: 100%;
  }

  .task-status-select {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .hd-status-select {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 44px;
    border-radius: 12px;
  }

  .task-card-actions {
    width: 100%;
    align-items: stretch;
  }

  .task-card-actions .btn,
  .task-card-actions .btn.secondary,
  .task-card-actions .btn.ghost {
    flex: 1 1 0;
    min-width: 0;
  }

  .table-wrapper,
  .card .table-wrapper,
  .scroll-x {
    overflow-x: visible;
  }

  .table {
    min-width: 0;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
  }

  .table thead {
    display: none;
  }

  .table tbody {
    display: block;
  }

  .table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }

  .table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border: none;
    padding: 9px 0;
    width: 100% !important;
    min-width: 0;
    white-space: normal !important;
  }

  .table td + td {
    border-top: 1px dashed var(--border);
  }

  .table td::before {
    content: attr(data-title);
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
    line-height: 1.25;
    flex: 0 0 38%;
    max-width: 38%;
    margin-right: 0;
    overflow-wrap: anywhere;
  }

  .table td:not([data-title])::before,
  .table td[data-title=""]::before {
    display: none;
  }

  .table td[colspan] {
    display: block;
    text-align: left;
  }

  .table td[colspan]::before {
    display: none;
  }

  .table td > * {
    max-width: 100%;
  }

  .table td:first-child a {
    white-space: normal;
  }

  .table td[data-title="Дії"],
  .table td:last-child {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .table td[data-title="Дії"]::before,
  .table td:last-child::before {
    width: 100%;
    flex-basis: 100%;
    max-width: none;
  }

  .table td[data-title="Дії"] .btn,
  .table td:last-child .btn {
    flex: 1 1 100%;
    width: 100%;
    min-height: 42px;
  }

  .vault-grid {
    grid-template-columns: 1fr;
  }

  .vault-item {
    padding: 12px;
    align-items: stretch;
  }

  .vault-item-main {
    flex-basis: 100%;
    min-width: 0;
  }

  .vault-actions {
    width: 100%;
    gap: 8px;
    align-items: stretch;
  }

  .vault-actions .btn,
  .vault-actions .btn.ghost,
  .vault-actions .btn.secondary {
    flex: 1 1 0;
    min-width: 0;
  }

  .vault-inline > input,
  .vault-inline > select {
    min-width: 0;
    flex-basis: 100%;
  }

  .vault-inline > .btn {
    width: 100%;
  }

  .vault-editor-actions {
    align-items: stretch;
  }

  .vault-editor-actions .btn,
  .vault-editor-actions .btn.ghost,
  .vault-editor-actions .btn.secondary {
    flex: 1 1 100%;
  }

  .vault-share {
    display: grid;
    grid-template-columns: 1fr;
  }

  .vault-chip {
    border-radius: 12px;
  }

  .admin-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .actions,
  .form-actions,
  .inline-actions {
    align-items: stretch;
  }

  .actions .btn,
  .form-actions .btn,
  .inline-actions .btn,
  .actions .btn.ghost,
  .form-actions .btn.ghost,
  .inline-actions .btn.ghost {
    flex: 1 1 100%;
  }

  .fc .fc-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .fc .fc-button {
    padding: 7px 9px !important;
    font-size: 13px !important;
  }
}

/* ==========================================================================
   Responsive — small phones
   ========================================================================== */

@media (max-width: 560px) {
  .site-header-top {
    align-items: flex-start;
  }

  .site-header .brand {
    max-width: calc(100vw - 120px);
    font-size: 16px;
  }

  .site-header-right {
    width: 100%;
    justify-content: flex-start;
  }

  .site-header-right .btn,
  .site-header-right .icon-btn {
    min-height: 38px;
  }

  .site-header-right .btn {
    flex: 1 1 auto;
  }

  .icon-btn,
  .nav-toggle {
    flex: 0 0 40px;
  }

  .container {
    padding: 14px 10px;
  }

  .card {
    padding: 12px;
    border-radius: 13px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  .home-clock-time {
    font-size: 34px;
  }

  .home-clock-date {
    font-size: 14px;
  }

  .home-task-link,
  .task-card-link {
    font-size: 15px;
  }

  .badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .tasks-filter-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .task-card-actions,
  .home-filters > div[style],
  .home-filters > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .task-card-actions .btn,
  .task-card-actions .btn.secondary,
  .task-card-actions .btn.ghost,
  .home-filters .btn,
  .home-filters .btn.ghost {
    width: 100%;
  }

  .table tr {
    padding: 10px;
  }

  .table td {
    display: block;
    padding: 9px 0;
  }

  .table td::before {
    display: block;
    max-width: none;
    margin: 0 0 4px;
  }

  .table td[data-title="Дії"] {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .vault-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .vault-filters input[type="text"],
  .vault-filters select,
  .vault-filters .btn,
  .vault-filters .btn.ghost {
    width: 100%;
    min-width: 0;
  }

  .vault-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .vault-list-head {
    flex-direction: column;
    align-items: stretch;
  }

  .hd-toast-wrap {
    right: 10px;
    left: 10px;
    bottom: calc(10px + var(--safe-bottom));
    max-width: none;
  }

  .hd-toast {
    border-radius: 13px;
  }
}

@media (max-width: 390px) {
  .container {
    padding-left: 8px;
    padding-right: 8px;
  }

  .site-header,
  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .card {
    padding: 10px;
  }

  .btn {
    padding-left: 10px;
    padding-right: 10px;
  }

  .home-meta-pill,
  .task-meta-pill {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .topbar,
  .site-header,
  .flash,
  .btn,
  nav,
  .hd-toast-wrap {
    display: none !important;
  }

  html,
  body {
    overflow: visible;
  }

  body {
    background: #fff;
    color: #000;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  .table {
    min-width: 0;
  }

  .table thead {
    display: table-header-group;
  }

  .table tr {
    break-inside: avoid;
  }
}

/* ==========================================================================
   Vault compact list - smaller fields, less empty space
   ========================================================================== */

.vault-main .vault-list {
  gap: 6px !important;
}

.vault-main .vault-item {
  padding: 10px 12px !important;
  gap: 8px !important;
  border-radius: 12px !important;
}

.vault-main .vault-item::before {
  top: 10px !important;
  bottom: 10px !important;
  width: 3px !important;
}

.vault-main .vault-item-title {
  margin-left: 2px !important;
  font-size: 15px !important;
  line-height: 1.15 !important;
  gap: 6px !important;
}

.vault-main .vault-pill {
  padding: 2px 8px !important;
  font-size: 10px !important;
  border-radius: 999px !important;
}

.vault-main .vault-item-main > div[style*="grid-template-columns"] {
  margin-top: 6px !important;
  grid-template-columns: minmax(95px, .65fr) minmax(150px, 1fr) minmax(150px, .95fr) minmax(170px, .95fr) !important;
  gap: 6px !important;
}

.vault-main .vault-item-main > div[style*="grid-template-columns"] > div {
  padding: 7px 9px !important;
  border-radius: 10px !important;
  min-height: auto !important;
}

.vault-main .vault-item-main > div[style*="grid-template-columns"] > div > .muted:first-child,
.vault-main .vault-item-main > div[style*="grid-template-columns"] > div > div.muted:first-child {
  margin-bottom: 3px !important;
  font-size: 10px !important;
  line-height: 1.05 !important;
  letter-spacing: .03em !important;
}

.vault-main .vault-item-main > div[style*="grid-template-columns"] b,
.vault-main .vault-item-main > div[style*="grid-template-columns"] code,
.vault-main .vault-item-main > div[style*="grid-template-columns"] > div > div:last-child {
  font-size: 13px !important;
  line-height: 1.2 !important;
}

.vault-main .vault-item-main code[id^="list_pass_mask_"] {
  padding: 4px 6px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
}

.vault-main .vault-item-main button,
.vault-main .vault-item-main .btn,
.vault-main .vault-item-main .vault-btn-sm {
  min-height: 30px !important;
  padding: 5px 9px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
}

.vault-main .vault-item-main > div[style*="margin-top:12px"][style*="padding:12px"] {
  margin-top: 6px !important;
  padding: 6px 9px !important;
  border-radius: 10px !important;
}

.vault-main .vault-item-main > div[style*="margin-top:12px"][style*="padding:12px"] .muted {
  margin-bottom: 2px !important;
  font-size: 10px !important;
}

.vault-main .vault-item-main > div[style*="margin-top:12px"][style*="padding:12px"] div:last-child {
  font-size: 12px !important;
  line-height: 1.25 !important;
}

.vault-main .vault-item-sub {
  margin-top: 4px !important;
  font-size: 10px !important;
  line-height: 1.2 !important;
}

.vault-main .vault-actions {
  gap: 6px !important;
  padding-top: 6px !important;
  margin-top: 0 !important;
}

.vault-main .vault-actions .btn,
.vault-main .vault-actions .vault-btn-sm {
  min-height: 30px !important;
  padding: 5px 9px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
}

@media (max-width: 1200px) {
  .vault-main .vault-item-main > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 720px) {
  .vault-main .vault-item {
    padding: 9px 10px 10px 11px !important;
  }

  .vault-main .vault-item-title {
    font-size: 14px !important;
  }

  .vault-main .vault-item-main > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 5px !important;
  }

  .vault-main .vault-item-main > div[style*="grid-template-columns"] > div {
    padding: 7px 8px !important;
  }

  .vault-main .vault-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }

  .vault-main .vault-actions .btn,
  .vault-main .vault-actions .vault-btn-sm {
    width: 100% !important;
    min-height: 36px !important;
  }
}

@media (max-width: 420px) {
  .vault-main .vault-actions {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   Printers page — Google Sheets style
   ========================================================================== */

body:has(#printersTable) .container {
  max-width: 1520px;
}

#printersTable {
  min-width: 980px;
  table-layout: fixed;
  border-collapse: collapse;
  border-spacing: 0;
  background: var(--surface);
  font-size: 13px;
}

#printersTable th,
#printersTable td {
  padding: 7px 10px;
  border: 1px solid var(--border);
  vertical-align: middle;
  background: var(--surface);
  line-height: 1.25;
}

#printersTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}

#printersTable tbody tr:hover td {
  background: rgba(14, 165, 233, .08);
}

#printersTable th:nth-child(1),
#printersTable td:nth-child(1) {
  width: 64px;
  text-align: center;
  color: var(--muted);
}

#printersTable th:nth-child(2),
#printersTable td:nth-child(2) {
  width: 120px;
}

#printersTable th:nth-child(3),
#printersTable td:nth-child(3) {
  width: 145px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

#printersTable th:nth-child(4),
#printersTable td:nth-child(4) {
  width: 330px;
  font-weight: 800;
}

#printersTable th:nth-child(5),
#printersTable td:nth-child(5) {
  width: 250px;
}

#printersTable th:nth-child(6),
#printersTable td:nth-child(6) {
  width: 130px;
  text-align: center;
}

#printersTable th:nth-child(7),
#printersTable td:nth-child(7) {
  width: 185px;
}

#printersTable a {
  font-weight: 850;
}

#printersTable .badge {
  min-width: 92px;
  min-height: 24px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
}

#printersTable td[data-title="Дії"] {
  gap: 6px !important;
  justify-content: flex-start;
}

#printersTable td[data-title="Дії"] .btn {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: none;
}

#printersTable td[data-title="Дії"] .btn.secondary {
  background: #475569;
}

#printersTable td[data-title="Дії"] .btn.secondary:hover {
  background: #334155;
}

/* Форма зверху — компактніше як панель таблиці */
body:has(#printersTable) .card:first-of-type {
  padding: 14px 16px;
}

body:has(#printersTable) .card:first-of-type h2 {
  font-size: 22px;
}

body:has(#printersTable) .card:first-of-type form.row {
  display: grid !important;
  grid-template-columns: 190px minmax(260px, 1fr) minmax(260px, 1fr) minmax(240px, 1fr);
  gap: 10px !important;
  align-items: end;
}

body:has(#printersTable) .card:first-of-type form.row > .col {
  min-width: 0 !important;
  width: 100%;
}

body:has(#printersTable) .card:first-of-type form.row > .col:nth-last-child(2),
body:has(#printersTable) .card:first-of-type form.row > .col:last-child {
  grid-column: 1 / -1;
}

body:has(#printersTable) .card:first-of-type label {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

body:has(#printersTable) .card:first-of-type input,
body:has(#printersTable) .card:first-of-type select {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
}

body:has(#printersTable) #btnPing {
  min-height: 38px;
  padding: 8px 12px;
}

body:has(#printersTable) #pingRes {
  min-height: 16px;
  margin-top: 4px !important;
  font-size: 12px;
}

/* Картка списку — як лист таблиці */
body:has(#printersTable) .card:has(#printersTable) {
  padding: 14px 16px 16px;
}

body:has(#printersTable) .card:has(#printersTable) h3 {
  font-size: 20px;
  font-weight: 900;
}

body:has(#printersTable) #autoPingNote {
  font-size: 12px;
  font-weight: 800;
}

body:has(#printersTable) .card:has(#printersTable) > div[style*="overflow"] {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto !important;
  max-height: calc(100vh - 360px);
  background: var(--surface);
}

/* Темна тема */
:root[data-theme="dark"] #printersTable th,
:root[data-theme="dark"] #printersTable td {
  background: #0f172a;
  border-color: #263244;
}

:root[data-theme="dark"] #printersTable thead th {
  background: #111c30;
}

:root[data-theme="dark"] #printersTable tbody tr:hover td {
  background: rgba(56, 189, 248, .10);
}

/* Телефон */
@media (max-width: 720px) {
  body:has(#printersTable) .card:first-of-type form.row {
    grid-template-columns: 1fr;
  }

  body:has(#printersTable) .card:has(#printersTable) > div[style*="overflow"] {
    max-height: none;
    border: none;
    border-radius: 0;
  }

  #printersTable {
    min-width: 0;
  }

  #printersTable tr {
    box-shadow: none;
  }

  #printersTable td {
    border: none;
    border-bottom: 1px solid var(--border);
  }

  #printersTable td[data-title="Дії"] .btn {
    min-height: 38px;
  }
}