/* ── RESET & TOKENS ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0d1117;
  --bg2: #161b24;
  --bg3: #1c2333;
  --bg4: #0a0e15;
  --border: #21293d;
  --border2: #2d3a52;
  --text: #dce6f5;
  --text2: #8da0bc;
  --text3: #4d6080;
  --accent: #4f8ef7;
  --accent-h: #6fa3ff;
  --accent-dim: #1a2e54;
  --green: #34d399;
  --green-bg: #0d2a1f;
  --yellow: #fbbf24;
  --yellow-bg: #2a1f08;
  --red: #f87171;
  --red-bg: #2a0d0d;
  --purple: #a78bfa;
  --purple-bg: #1e1533;
  --sidebar-w: 210px;
  --bottom-bar-h: 58px;
  --ctrl-h: 48px;
  --r4: 4px;
  --r8: 8px;
  --r12: 12px;
  --r16: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ───────────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* ── BASE ────────────────────────────────────────────────────────── */
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  color: var(--accent-h);
}
code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text2);
}
button,
select,
input,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--r8);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    opacity 0.15s,
    transform 0.1s;
  white-space: nowrap;
  line-height: 1;
}
.btn:active {
  transform: scale(0.96);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-h);
}
.btn-secondary {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-secondary:hover {
  background: var(--border2);
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg3);
  color: var(--text);
}
.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #4a1010;
}
.btn-danger:hover {
  background: #3a1010;
}
.btn-sm {
  padding: 0.38rem 0.8rem;
  font-size: 0.82rem;
}
.btn-icon {
  padding: 0.4rem 0.5rem;
}
.btn-block {
  width: 100%;
  justify-content: flex-start;
}

/* ── INPUTS ──────────────────────────────────────────────────────── */
input[type='text'],
input[type='number'],
input[type='date'],
input[type='url'],
input[type='email'],
select,
textarea {
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  color: var(--text);
  border-radius: var(--r8);
  padding: 0.6rem 0.9rem;
  width: 100%;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  font-size: 0.92rem;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.18);
}
input::placeholder,
textarea::placeholder {
  color: var(--text3);
}
select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%234d6080' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.1rem;
}
textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-row {
  display: grid;
  gap: 0.75rem;
}
.form-row-2 {
  grid-template-columns: 1fr 1fr;
}
.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ── CONNECT SCREEN ──────────────────────────────────────────────── */
#connectScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  gap: 1.5rem;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79, 142, 247, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(167, 139, 250, 0.06) 0%, transparent 50%), var(--bg);
}
.connect-logo {
  font-size: 3.5rem;
  line-height: 1;
}
.connect-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r16);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
}
.connect-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}
.connect-card .sub {
  color: var(--text3);
  font-size: 0.88rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}
.connect-btns {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.connect-btns .btn {
  justify-content: flex-start;
  padding: 0.75rem 1.2rem;
}
.connect-btns .btn span + span {
  white-space: normal;
  word-break: break-word;
  width: 100%;
}
.connect-or {
  text-align: center;
  color: var(--text3);
  font-size: 0.8rem;
  padding: 0.4rem 0;
}

/* ── APP LAYOUT ──────────────────────────────────────────────────── */
#mainApp {
  display: none;
  height: 100%;
}
#mainApp.visible {
  display: flex;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-logo {
  padding: 1.1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  font-size: 1.3rem;
}
.sidebar-logo span {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--r8);
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
}
.nav-link:hover {
  background: var(--bg3);
  color: var(--text2);
}
.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent-h);
}
.nav-link .nl-ico {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex-shrink: 0;
}
.btn-ico {
  flex-shrink: 0;
}
.btn-lbl {
  flex: 1;
}
.dirty-indicator {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--yellow);
  font-weight: 600;
  padding: 0.1rem 0.2rem;
}
.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ── LANGUAGE BAR ────────────────────────────────────────────────── */
#langBar {
  position: fixed;
  top: 0.55rem;
  right: 0.75rem;
  z-index: 70;
  display: flex;
  gap: 0.2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r8);
  padding: 0.18rem 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.lang-btn {
  padding: 0.25rem 0.38rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--r4);
  border: 1px solid transparent;
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
}
.lang-btn:hover {
  background: var(--bg3);
  color: var(--text2);
}
.lang-btn.active {
  background: var(--accent-dim);
  color: var(--accent-h);
  border-color: var(--accent-dim);
}

/* ── MAIN CONTENT ────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ── CONTROLS ────────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.96);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.controls-inner {
  display: flex;
  gap: 0.45rem;
  padding: 0.5rem 1.25rem;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  row-gap: 0.4rem;
}
.search-wrap {
  position: relative;
  flex-shrink: 0;
  width: 200px;
}
.search-ico {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
  width: 14px;
  height: 14px;
}
.search-wrap input {
  padding: 0.4rem 0.65rem 0.4rem 1.9rem;
  font-size: 0.9rem;
  width: 100%;
}
.ctrl-sep {
  width: 1px;
  height: 20px;
  background: var(--border2);
  flex-shrink: 0;
  margin: 0 0.05rem;
}
.controls-inner select {
  font-size: 0.88rem;
  padding: 0.4rem 1.9rem 0.4rem 0.65rem;
  width: auto;
  flex-shrink: 0;
}
.controls-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  padding-right: 88px;
}
.stats-bar {
  font-size: 0.88rem;
  color: var(--text3);
  white-space: nowrap;
}
.stats-bar b {
  color: var(--text);
  font-weight: 700;
}
.btn-reset {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: var(--r8);
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-reset:hover {
  background: var(--bg3);
  color: var(--text);
}
.btn-reset.visible {
  display: flex;
}

/* Mobile filter button — hidden on desktop */
.btn-filter-mobile {
  display: none;
  position: relative;
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: var(--r8);
  padding: 0.35rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-filter-mobile:hover {
  background: var(--bg3);
  color: var(--text);
}
.btn-filter-mobile.has-filters {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── VIEWS ───────────────────────────────────────────────────────── */
#listView,
#settingsView {
  display: none;
}
#listView.active,
#settingsView.active {
  display: block;
}
.view {
  padding: 1.5rem;
}

/* ── TABLE ───────────────────────────────────────────────────────── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  table-layout: fixed;
}
.items-table col.col-name {
  width: 28%;
}
.items-table col.col-brand {
  width: 9%;
}
.items-table col.col-shop {
  width: 16%;
}
.items-table col.col-date {
  width: 8%;
}
.items-table col.col-price {
  width: 9%;
}
.items-table col.col-warranty {
  width: 12%;
}
.items-table col.col-status {
  width: 7%;
}

.items-table thead {
  position: sticky;
  top: var(--ctrl-h);
  z-index: 30;
  background: var(--bg4);
}
.items-table th {
  padding: 0.65rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border2);
  white-space: nowrap;
  user-select: none;
}
.th-sort {
  cursor: pointer;
}
.th-sort:hover {
  color: var(--text2);
}
.th-sort.active {
  color: var(--accent);
}
.sort-ico {
  display: inline-block;
  margin-left: 0.3rem;
  opacity: 0.45;
  font-size: 0.85em;
  font-style: normal;
}
.th-sort.active .sort-ico {
  opacity: 1;
}
.th-price,
.td-price {
  text-align: right;
}
.th-warranty,
.td-warranty {
  text-align: center;
}
.td-warranty .badge {
  min-width: 76px;
  justify-content: center;
}
.warranty-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.warranty-date {
  font-size: .73rem;
  color: var(--text3);
  line-height: 1.2;
  min-height: 1em;
}
.th-status,
.td-status {
  text-align: center;
}

/* ── TABLE ROWS ──────────────────────────────────────────────────── */
.items-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.98rem;
  overflow: hidden;
}
.group-hdr {
  cursor: pointer;
  transition: filter 0.12s;
}
.group-hdr:hover > td {
  filter: brightness(1.12);
}
.group-hdr td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border2);
}
.group-hdr-inner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.g-chevron {
  font-size: 0.8rem;
  color: var(--text3);
  transition: transform 0.2s;
  display: inline-block;
  width: 14px;
}
.g-chevron.open {
  transform: rotate(90deg);
}
.g-order {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.g-date {
  font-size: 0.85rem;
  color: var(--text3);
}
.g-count {
  font-size: 0.75rem;
  color: var(--text3);
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 6px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.g-sum {
  font-weight: 800;
  font-size: 0.97rem;
  color: var(--text);
  margin-left: auto;
}
.g-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.g-more {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text3);
  margin-left: 0.3rem;
}
.g-month-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}
.g-cat-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.item-tr {
  cursor: pointer;
  transition: background 0.12s;
}
.item-tr:hover {
  background: rgba(255, 255, 255, 0.025);
}
.item-tr.open {
  background: rgba(79, 142, 247, 0.07);
}
.td-name {
  font-weight: 600;
  color: var(--text);
}
.td-name-inner {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.td-brand {
  color: var(--text2);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.td-shop {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.td-date {
  color: var(--text2);
  white-space: nowrap;
  font-size: 0.9rem;
}
.td-price {
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.td-warranty {
  white-space: nowrap;
}
.detail-tr td {
  padding: 0;
  background: var(--bg4);
  border-bottom: 2px solid var(--accent-dim);
}

/* ── DETAIL PANEL ────────────────────────────────────────────────── */
.item-detail {
  padding: 1rem 1.25rem;
}
.item-detail-inner {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  align-items: start;
}
.detail-left {
  padding: 0 1.5rem 0 0;
  border-right: 1px solid var(--border);
}
.detail-right {
  padding: 0 0 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.detail-specs {
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  gap: 0.25rem 1.25rem;
}
.spec-entry {
  display: contents;
}
.spec-k {
  color: var(--text3);
  font-size: 0.83rem;
  white-space: nowrap;
  align-self: baseline;
  padding: 0.1rem 0;
}
.spec-v {
  color: var(--text2);
  font-weight: 500;
  word-break: break-word;
  font-size: 0.95rem;
  padding: 0.1rem 0;
}
.detail-note {
  background: var(--bg3);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r4) var(--r4) 0;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  color: var(--text2);
  margin-top: 0.85rem;
}
.dr-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.dr-title {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.15rem;
}
.detail-links {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.ev-compact {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(33, 41, 61, 0.5);
  font-size: 0.86rem;
}
.ev-compact:last-child {
  border-bottom: none;
}
.ev-compact-header {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}
.ev-date {
  color: var(--text3);
  flex-shrink: 0;
  font-size: 0.82rem;
}
.ev-type-label {
  font-weight: 600;
}
.ev-type-warranty_claim {
  color: var(--yellow);
}
.ev-type-repair {
  color: var(--accent);
}
.ev-type-returned {
  color: var(--purple);
}
.ev-type-note {
  color: var(--text3);
}
.ev-compact-note {
  color: var(--text3);
  font-size: 0.82rem;
  margin-top: 0.05rem;
}
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

/* ── BADGES ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-ok {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid #0d3a27;
}
.badge-warn {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid #3a2808;
}
.badge-expired {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #3a1010;
}
.badge-none {
  background: var(--bg3);
  color: var(--text3);
  border: 1px solid var(--border);
}
.badge-returned {
  background: var(--purple-bg);
  color: var(--purple);
  border: 1px solid #2e1f52;
}
.badge-written_off {
  background: #111;
  color: var(--text3);
  border: 1px solid var(--border);
}
.badge-status-active {
  background: #0d2a1f;
  color: var(--green);
  border: 1px solid #0d3a27;
}
.badge-status-returned {
  background: var(--purple-bg);
  color: var(--purple);
  border: 1px solid #2e1f52;
}
.badge-status-written_off {
  background: #111;
  color: var(--text3);
  border: 1px solid var(--border);
}
.wdot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wdot-ok {
  background: var(--green);
}
.wdot-warn {
  background: var(--yellow);
}
.wdot-expired {
  background: var(--red);
}
.shop-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r4);
  white-space: nowrap;
}
.order-num {
  font-size: 0.83rem;
  color: var(--text3);
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 1px 7px;
  border-radius: var(--r4);
  font-weight: 500;
  background: var(--bg3);
  color: var(--text3);
  border: 1px solid var(--border);
}

/* ── MODAL ───────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r16);
  width: 100%;
  max-width: 680px;
  margin: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-hd h2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border-radius: var(--r4);
}
.modal-close:hover {
  color: var(--text);
  background: var(--bg3);
}
.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 78vh;
  overflow-y: auto;
}
.modal-ft {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
body.modal-open {
  overflow: hidden;
}

/* ── FILTER BOTTOM SHEET ─────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r16) var(--r16) 0 0;
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow);
  animation: sheetIn 0.22s ease;
}
.sheet-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.sheet-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 60vh;
  overflow-y: auto;
}
.sheet-ft {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.sheet-lang {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  padding-top: 0.25rem;
}

/* ── COLOR PICKER ────────────────────────────────────────────────── */
.color-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.color-field input[type='color'] {
  width: 44px;
  height: 36px;
  padding: 2px 3px;
  border-radius: var(--r8);
  cursor: pointer;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
}
.color-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.color-preset {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition:
    transform 0.15s,
    border-color 0.15s;
  flex-shrink: 0;
}
.color-preset:hover {
  transform: scale(1.2);
}
.color-preset.active {
  border-color: var(--text);
}

/* ── SPECS / EVENTS / RECEIPTS EDITORS ───────────────────────────── */
.specs-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.spec-row-edit {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.35rem;
  align-items: center;
}
.spec-row-edit input {
  padding: 0.42rem 0.65rem;
  font-size: 0.85rem;
}
.events-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.ev-edit-row {
  display: grid;
  grid-template-columns: 120px 150px 1fr auto;
  gap: 0.35rem;
  align-items: start;
}
.ev-edit-row input,
.ev-edit-row select {
  padding: 0.4rem 0.6rem;
  font-size: 0.84rem;
}
.receipts-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.receipt-row-edit {
  display: grid;
  grid-template-columns: 130px 130px 1fr auto;
  gap: 0.35rem;
  align-items: center;
}
.receipt-row-edit input,
.receipt-row-edit select {
  padding: 0.42rem 0.65rem;
  font-size: 0.85rem;
}
.spec-del {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  cursor: pointer;
  border-radius: var(--r8);
  padding: 0.38rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s;
}
.spec-del:hover {
  background: var(--red-bg);
  border-color: #4a1010;
  color: var(--red);
}

/* ── SETTINGS ────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 860px;
}
.settings-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r12);
  overflow: hidden;
}
.settings-card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.settings-card-hd h3 {
  font-size: 0.92rem;
  font-weight: 700;
}
.settings-list {
  display: flex;
  flex-direction: column;
}
.settings-list-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid rgba(33, 41, 61, 0.5);
}
.settings-list-item:last-child {
  border-bottom: none;
}
.sli-info {
  flex: 1;
  min-width: 0;
}
.sli-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.sli-sub {
  font-size: 0.76rem;
  color: var(--text3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sli-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

/* ── EMPTY ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text3);
}
.empty-state .empty-ico {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}
.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 0.35rem;
}
.empty-state p {
  font-size: 0.88rem;
  max-width: 300px;
  margin: 0 auto;
}

/* ── TOAST ───────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r12);
  padding: 0.65rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  transform: translateY(1rem);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.22s,
    opacity 0.22s;
  max-width: 320px;
  box-shadow: var(--shadow);
}
#toast.show {
  transform: none;
  opacity: 1;
}
#toast.ok {
  border-color: #134a2a;
  color: var(--green);
  background: #0a1f13;
}
#toast.err {
  border-color: #4a1010;
  color: var(--red);
  background: #1a0808;
}

/* ── MOBILE META ─────────────────────────────────────────────────── */
.mobile-meta {
  display: none;
}
.mm-price {
  display: none;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
}
.mm-warranty {
  display: none;
}

/* ══════════════════════════════════════════════════════════════════ */
/* ── RESPONSIVE ──────────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════════ */

/* 1100px: hide status col, show in mobile-meta */
@media (max-width: 1100px) {
  .col-status,
  .td-status {
    display: none;
  }
  .mobile-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
  }
}

/* ── TABLET + MOBILE ≤1400px — bottom nav bar layout ────────────── */
@media (max-width: 1400px) {
  :root {
    --bottom-bar-h: 64px;
  }

  /* Filter button visible, desktop filters hidden */
  .btn-filter-mobile {
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }
  .desktop-filter {
    display: none !important;
  }
  .ctrl-sep {
    display: none;
  }

  /* Lang bar hidden — accessible via filter sheet */
  #langBar {
    display: none;
  }

  /* Sidebar: bottom tab bar */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    overflow: hidden;
    z-index: 60;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar-logo {
    display: none;
  }
  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    padding: 0 0.35rem;
    gap: 0;
    overflow: hidden;
  }
  .nav-link {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-link .nl-ico {
    font-size: 1.4rem;
    width: auto;
  }
  .nav-link span:not(.nl-ico) {
    display: block;
    font-size: 0.75rem;
  }
  .sidebar-footer {
    flex-direction: row;
    padding: 0.4rem 0.6rem;
    border-top: none;
    border-left: 1px solid var(--border);
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
  }
  .dirty-indicator {
    display: none !important;
  }
  .sidebar-footer .btn {
    width: auto;
    padding: 0.5rem 0.85rem;
    font-size: 1.05rem;
  }
  .sidebar-footer .btn-lbl {
    display: none;
  }

  /* Main content — padding for bottom bar */
  .main-content {
    padding-bottom: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
  }

  /* Controls: single row */
  .controls-inner {
    padding: 0.4rem 1rem;
  }
  .controls-right {
    margin-left: auto;
    padding-right: 0;
  }
  .search-wrap {
    flex: 1;
    width: auto;
    min-width: 120px;
  }

  /* Modals as bottom sheets */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
    padding-top: 3.5rem;
  }
  .modal {
    border-radius: var(--r12) var(--r12) 0 0;
    margin: 0;
    max-width: 100%;
    animation: sheetIn 0.2s ease;
  }
  @keyframes sheetIn {
    from {
      transform: translateY(24px);
      opacity: 0;
    }
    to {
      transform: none;
      opacity: 1;
    }
  }
  .modal-body {
    max-height: 65vh;
  }
}

/* 900px: hide brand/warranty cols */
@media (max-width: 900px) {
  .col-brand,
  .col-warranty,
  .td-warranty {
    display: none;
  }
  .mm-warranty {
    display: contents;
  }
}

/* 768px: hide shop/date cols */
@media (max-width: 768px) {
  .col-shop,
  .col-date {
    display: none;
  }
  .item-detail-inner {
    grid-template-columns: 1fr;
  }
  .detail-left {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
  }
  .detail-right {
    padding-left: 0;
  }
  .receipt-row-edit {
    grid-template-columns: 110px 1fr auto;
  }
  .receipt-row-edit .rcpt-label {
    display: none;
  }
}

/* ── MOBILE ≤600px — size overrides on top of ≤960px layout ─────── */
@media (max-width: 600px) {
  :root {
    --ctrl-h: 48px;
    --bottom-bar-h: 58px;
  }

  /* Smaller nav items */
  .nav-link {
    gap: 0.08rem;
    padding: 0.3rem 0.25rem;
    font-size: 0.62rem;
  }
  .nav-link .nl-ico {
    font-size: 1.25rem;
  }
  .nav-link span:not(.nl-ico) {
    font-size: 0.62rem;
  }
  .sidebar-footer {
    padding: 0.3rem 0.45rem;
    gap: 0.3rem;
  }
  .sidebar-footer .btn {
    padding: 0.42rem 0.7rem;
    font-size: 1rem;
  }

  /* Controls tighter */
  .controls-inner {
    padding: 0.4rem 0.85rem;
  }
  .search-wrap {
    min-width: 80px;
  }

  /* Hide price column, reveal inline */
  .col-price,
  .td-price {
    display: none;
  }
  .mm-price {
    display: block;
  }
  .items-table col.col-name {
    width: 100%;
  }
  .items-table td {
    padding: 0.75rem 0.85rem;
  }
  .items-table th {
    padding: 0.6rem 0.85rem;
  }

  /* Forms 1-column */
  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr;
  }
  .modal-body {
    padding: 1rem;
  }
  .modal-hd,
  .modal-ft {
    padding: 0.85rem 1rem;
  }
  .ev-edit-row {
    grid-template-columns: 1fr 1fr auto;
  }
  .ev-edit-row .ev-note-f {
    grid-column: 1/-1;
  }
  .receipt-row-edit {
    grid-template-columns: 110px 1fr auto;
  }
  .receipt-row-edit .rcpt-label {
    display: none;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }

  /* Touch-friendly tap targets */
  input,
  select,
  textarea {
    min-height: 44px;
  }
  .controls-inner input,
  .controls-inner select {
    min-height: unset;
  }
  .btn-sm {
    padding: 0.55rem 0.9rem;
  }
  .spec-del {
    padding: 0.55rem 0.65rem;
  }

  /* Connect screen */
  #connectScreen {
    padding: 1.25rem 1rem;
    gap: 1rem;
  }
  .connect-logo {
    font-size: 2.5rem;
  }
  .connect-card {
    padding: 1.5rem 1.1rem;
  }
  .connect-card h1 {
    font-size: 1.2rem;
  }
}

/* ── Import via AI modal ── */
.import-modal-wide {
  max-width: 1300px !important;
  width: 98vw;
}
.import-modal-body {
  display: flex;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 1.5rem;
  padding-bottom: 0 !important;
}
.import-col-inputs {
  flex: 0 0 54%;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.import-col-inputs .form-group {
  margin-bottom: 0.85rem;
}
.import-desc-input {
  resize: vertical;
  min-height: 90px;
}
.import-file-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.import-file-names {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.import-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-family: monospace;
  color: var(--accent-h);
  background: var(--accent-dim);
  border-radius: 5px;
  padding: 0.2rem 0.4rem 0.2rem 0.55rem;
  max-width: 100%;
}
.import-file-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.import-file-remove:hover {
  color: var(--red);
}
.import-file-hint {
  display: none;
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: #c8a020;
  line-height: 1.4;
}
.import-file-hint.visible {
  display: block;
}
.import-col-help {
  flex: 1;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
}
.import-how-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}
.import-steps-list {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.import-steps-list li {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.45;
}
.import-example-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  margin-top: 0.3rem;
}
.import-example-json {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text3);
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  flex: 1;
}
.import-json-section {
  padding: 1rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.import-step-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.import-json-input {
  width: 100%;
  min-height: 110px;
  font-family: monospace;
  font-size: 0.82rem;
  resize: vertical;
  background: var(--bg4);
  border: 1.5px solid var(--border2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  line-height: 1.5;
}
.import-json-input:focus {
  outline: none;
  border-color: var(--accent);
}
.import-preview {
  margin-top: 0.1rem;
}
.import-preview-card {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.import-preview-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.import-preview-meta {
  font-size: 0.82rem;
  color: var(--text2);
}
.import-preview-row {
  display: flex;
  gap: 1.2rem;
  font-size: 0.85rem;
  color: var(--accent-h);
}
.import-preview-serial {
  font-size: 0.8rem;
  color: var(--text3);
}
.import-preview-note {
  font-size: 0.82rem;
  color: var(--text3);
  font-style: italic;
}
.import-error {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
.import-error small {
  opacity: 0.75;
  font-family: monospace;
  display: block;
  margin-top: 0.25rem;
}
.import-warnings {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.import-warn {
  font-size: 0.82rem;
  color: var(--yellow);
  background: var(--yellow-bg);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
}

@media (max-width: 780px) {
  .import-modal-wide {
    width: 100vw;
    max-width: 100vw !important;
    border-radius: 0;
    margin: 0;
    max-height: 100dvh;
  }
  .import-modal-body {
    flex-direction: column !important;
  }
  .import-col-inputs {
    flex: 1;
    width: 100%;
  }
  .import-col-help {
    display: none;
  }
}
