:root {
  --bg: #f4f7fb;
  --paper: rgba(255, 255, 255, 0.9);
  --ink: #1e2838;
  --muted: #6f7f95;
  --line: #dce3ef;
  --brand: #1f9b84;
  --brand-2: #2b75eb;
  --danger: #de4e4e;
  --shadow: 0 18px 48px rgba(29, 47, 75, 0.14);
  --checked-bg: rgba(15, 118, 110, 0.08);
  --checked-border: rgba(15, 118, 110, 0.2);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 8% 12%, #e9f7f6 0%, transparent 32%),
              radial-gradient(circle at 90% 88%, #e8f1ff 0%, transparent 35%),
              var(--bg);
  min-height: 100vh;
}
.bg-shape { position: fixed; z-index: -1; border-radius: 999px; filter: blur(30px); }
.bg-one { width: 360px; height: 360px; background: #b0eedf; top: -100px; left: -120px; }
.bg-two { width: 340px; height: 340px; background: #c5dbff; bottom: -90px; right: -100px; }

.app-shell { max-width: 1320px; margin: 24px auto; padding: 0 18px 24px; }
.card { background: var(--paper); border: 1px solid #ecf1f8; border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.auth-card { max-width: 470px; margin: 44px auto; padding: 26px; }
.muted { color: var(--muted); margin-top: 2px; }

/* Auth */
.tabs { display: flex; gap: 8px; margin: 16px 0; }
.tab { border: 1px solid var(--line); border-radius: 999px; background: #f3f7fc; padding: 8px 14px; cursor: pointer; font: inherit; }
.tab.active { background: #18283f; color: #fff; border-color: #18283f; }
.form-grid, .row-wrap { display: flex; gap: 10px; flex-wrap: wrap; }
.form-grid input, .form-grid select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: #fff; }
.hidden { display: none !important; }
.error { color: #b8223c; min-height: 20px; }

/* Top bar */
.topbar { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px; margin-bottom: 14px; align-items: center; }
.topbar-left { display: flex; flex-direction: column; gap: 4px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input { width: 200px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: #fff; }

/* Layout */
.layout { display: grid; grid-template-columns: 300px 1fr 300px; gap: 14px; }
.pane { padding: 14px; min-height: 68vh; }
.main-pane { min-height: 68vh; }
.pane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pane-head.split { margin-bottom: 14px; }
.row-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.list-group { display: grid; gap: 10px; }

/* List cards */
.list-card { border: 1px solid var(--line); border-radius: 14px; padding: 11px; background: rgba(255,255,255,0.9); cursor: pointer; transition: box-shadow 0.15s; }
.list-card:hover { box-shadow: 0 4px 16px rgba(29, 47, 75, 0.1); }
.list-card.active { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(43,117,235,0.15); }
.list-card.archived { opacity: 0.65; }
.list-card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list-desc { font-size: 0.85em; margin-top: 4px; color: var(--muted); }
.archive-badge {
  font-size: 0.7em; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: #f1f5fb; color: var(--muted); border-radius: 6px; padding: 2px 6px;
}

/* Item cards */
.item-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 11px; background: rgba(255,255,255,0.9); transition: background 0.2s, border-color 0.2s; }
.item-card.checked { background: var(--checked-bg); border-color: var(--checked-border); }
.item-main { display: flex; flex-direction: column; gap: 2px; }
.item-name.checked { text-decoration: line-through; color: var(--muted); }
.item-note { font-size: 0.85em; color: var(--muted); }
.item-actions { display: flex; gap: 8px; }
.items { display: grid; gap: 10px; margin-top: 8px; }

/* Section divider */
.section-divider { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.divider-line { flex: 1; height: 1px; background: var(--line); }
.divider-label { font-size: 0.8em; font-weight: 600; color: var(--muted); white-space: nowrap; }
.clear-checked-btn { font-size: 0.8em !important; padding: 4px 10px !important; white-space: nowrap; }

/* Connection badge */
.connection-badge { display: inline-block; font-size: 0.78em; font-weight: 700; padding: 3px 10px; border-radius: 999px; min-height: 22px; transition: background 0.2s; }
.badge-online { background: rgba(15, 118, 110, 0.12); color: #0f766e; }
.badge-connecting { background: rgba(100, 116, 139, 0.12); color: var(--muted); }

/* Color dot */
.color-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

/* Categories */
.cat-row { display: flex; align-items: center; gap: 8px; }
.cat-icon { font-size: 1.1em; line-height: 1; }

/* Color picker */
.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform 0.1s, border-color 0.1s; flex-shrink: 0; padding: 0;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(255,255,255,0.85) inset; }

/* Qty stepper */
.qty-stepper { display: flex; align-items: center; gap: 8px; }
.qty-stepper input { width: 60px !important; text-align: center; padding: 9px 8px !important; }
.form-label { font-size: 0.82em; font-weight: 600; color: var(--muted); margin-top: 2px; }

/* Buttons */
.btn { border: none; border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 700; font: inherit; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: var(--brand-2); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #f1f5fb; color: var(--ink); }
.btn-mini { background: #edf3fb; padding: 8px 11px; color: var(--ink); font-size: 0.9em; }
.btn-icon { padding: 7px 11px; font-size: 20px; line-height: 1; }

/* Misc */
.empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); }
.panel-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid #edf2f8; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 29, 48, 0.5); display: grid; place-items: center; z-index: 30; }
.modal { width: min(560px, calc(100% - 28px)); padding: 16px; border-radius: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* Profile */
.btn-avatar {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; border: none;
  background: var(--brand); color: #fff; cursor: pointer; font-weight: 700;
  font-size: 0.9em; font-family: inherit; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.btn-avatar:hover { opacity: 0.85; }
.profile-header { text-align: center; padding: 6px 0 14px; }
.profile-avatar {
  width: 60px; height: 60px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6em; font-weight: 700; margin: 0 auto 10px;
}
.profile-name { font-size: 1.05em; font-weight: 700; }

/* Invite banner on auth screen */
.invite-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(31, 155, 132, 0.1); border: 1px solid rgba(31, 155, 132, 0.3);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 0.9em; color: #0f5147; line-height: 1.4;
}
.invite-banner-icon { font-size: 1.1em; flex-shrink: 0; }

/* Invite section */
.invite-section-container { margin-top: 12px; }
.invite-block { border: 1px dashed var(--brand); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.invite-label { font-size: 0.82em; font-weight: 700; color: var(--brand); }
.invite-desc { font-size: 0.82em; color: var(--muted); }
.invite-role-chip { background: rgba(31,155,132,0.12); color: var(--brand); border-radius: 6px; padding: 1px 6px; font-weight: 700; }
.invite-url-row { display: flex; gap: 6px; align-items: center; }
.invite-url-input { flex: 1; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 0.82em; background: #f7fafd; color: var(--muted); min-width: 0; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .pane, .main-pane { min-height: auto; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .toolbar { width: 100%; }
  .toolbar input { width: 100%; }
}
