/* Sign-in, account and admin pages. Builds on styles.css (tokens, buttons, fields, chips). */
[hidden] { display: none !important; }
body.app { background: #EFECE6; min-height: 100vh; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

/* ---------- Sign in / sign up / setup ---------- */
.auth { display: grid; grid-template-columns: 5fr 6fr; min-height: 100vh; }
.auth-side {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px clamp(24px, 5vw, 64px);
  color: var(--paper);
  background:
    radial-gradient(900px 500px at 90% 0%, rgba(167, 167, 167, .16), transparent 60%),
    radial-gradient(700px 400px at 0% 100%, rgba(201, 169, 107, .12), transparent 60%),
    linear-gradient(160deg, #18181B, var(--obsidian) 60%);
}
.auth-side .brand-mark { width: 84px; height: 34px; }
.auth-side h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 300; max-width: 22rem; }
.auth-side p { color: rgba(246, 244, 240, .7); max-width: 24rem; }
.auth-side .tagline { margin: 0; }
.auth-main { display: grid; place-items: center; padding: 48px var(--gutter); background: var(--paper); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .field input { background: #fff; border-color: var(--line-light); }
.auth-card .field input:focus { border-color: var(--obsidian); }
.auth-card h2 { margin-bottom: .5rem; }
.auth-card > p { color: var(--ink-soft); margin-bottom: 2rem; }
.auth-switch { margin-top: 1.5rem; text-align: center; font-size: .9rem; color: var(--ink-soft); }
.auth-switch a { font-weight: 600; color: var(--obsidian); }
.back-home { display: inline-block; margin-bottom: 2.5rem; font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; text-decoration: none; color: var(--ink-soft); }
.back-home:hover { color: var(--obsidian); }
.field input[disabled] { color: var(--ink-soft); cursor: not-allowed; }
.captcha { margin: 4px 0 16px; min-height: 65px; }
.captcha.pow { min-height: 0; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 52px !important; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.pw-toggle:hover { color: var(--obsidian); background: rgba(11, 11, 13, .06); }
.pw-toggle[aria-pressed="true"] { color: var(--obsidian); }
.field small { display: block; margin-top: .35rem; font-size: .78rem; color: var(--ink-soft); }

/* ---------- App shell (account + admin) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 64px; padding: 0 var(--gutter);
  background: var(--obsidian); color: var(--paper);
}
.topbar .brand { color: var(--paper); }
.topbar .brand-mark { width: 54px; height: 22px; }
.topbar-right { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar-user { display: flex; align-items: center; gap: .6rem; font-size: .85rem; min-width: 0; }
.topbar-user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sand), var(--gold)); color: var(--obsidian);
  font-size: .75rem; font-weight: 700;
}
.btn-topbar { min-height: 36px; padding: .5rem .9rem; font-size: .66rem; color: var(--paper); border-color: rgba(255, 255, 255, .25); background: transparent; }
.btn-topbar:hover { border-color: var(--paper); }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 64px); }
.sidebar { background: #fff; border-right: 1px solid var(--line-light); padding: 24px 14px; }
.sidebar nav { display: grid; gap: 4px; position: sticky; top: 88px; }
.side-link {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .7rem .9rem; border-radius: 10px;
  font-size: .9rem; font-weight: 500; text-decoration: none; color: var(--slate);
  transition: background .15s;
}
.side-link:hover { background: var(--paper); }
.side-link.active { background: var(--obsidian); color: var(--paper); }
.side-link .count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--obsidian); font-size: .72rem; font-weight: 700; text-align: center; line-height: 22px; }
.side-label { margin: 18px .9rem 6px; font-size: .64rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--stone); }

.content { padding: clamp(20px, 3.5vw, 40px); min-width: 0; max-width: 1240px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); font-weight: 500; }
.page-head p { margin: .35rem 0 0; color: var(--ink-soft); }
.back-link { display: inline-block; margin-bottom: .75rem; font-size: .8rem; font-weight: 600; text-decoration: none; color: var(--ink-soft); }
.back-link:hover { color: var(--obsidian); }

.panel { background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); padding: clamp(18px, 2.5vw, 28px); }
.panel + .panel { margin-top: 20px; }
.panel-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.panel-grid .panel + .panel { margin-top: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); padding: 20px; text-decoration: none; }
.stat.dark { background: var(--obsidian); color: var(--paper); border-color: var(--obsidian); }
.stat-label { font-size: .68rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--stone); }
.stat-value { display: block; margin-top: .4rem; font-size: 2rem; font-weight: 300; line-height: 1.1; }
.pipeline { display: flex; flex-wrap: wrap; gap: 8px; }
.pipeline a { flex: 1 1 120px; padding: 12px 14px; border-radius: 10px; background: var(--paper); text-decoration: none; }
.pipeline a:hover { background: var(--sand); }
.pipeline strong { display: block; font-size: 1.4rem; font-weight: 500; }
.pipeline span { font-size: .78rem; color: var(--ink-soft); }

/* Badges */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .7rem; font-weight: 600; letter-spacing: .03em; white-space: nowrap; background: var(--paper); color: var(--slate); }
.status-new { background: #E9E1FF; color: #3E2A8C; }
.status-reviewing { background: #FFF1D6; color: #7A5200; }
.status-quoted { background: #F3E9D7; color: #6B4E16; }
.status-in_progress { background: #DDEBFF; color: #1A4B8F; }
.status-completed { background: #DDF3E4; color: #1D6B3A; }
.status-closed { background: #ECECEC; color: #555; }
.badge-alert { background: var(--gold); color: var(--obsidian); }
.badge-note { background: #FFF1D6; color: #7A5200; }
.badge-role-superadmin { background: var(--obsidian); color: var(--paper); }
.badge-role-admin { background: var(--sand); color: var(--obsidian); }
.badge-off { background: #FBE4E2; color: #8C1D18; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filters input, .filters select {
  padding: .65rem .9rem; font: inherit; font-size: .9rem;
  background: #fff; border: 1px solid var(--line-light); border-radius: 10px;
}
.filters input[type=search] { flex: 1 1 220px; min-width: 0; }
.toggle { display: inline-flex; align-items: center; gap: .5rem; padding: .65rem .9rem; background: #fff; border: 1px solid var(--line-light); border-radius: 10px; font-size: .9rem; cursor: pointer; }

/* Lists */
.rows { background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 70px minmax(0, 2fr) minmax(0, 2fr) 120px 110px; gap: 16px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--line-light); text-decoration: none;
}
.row:first-child { border-top: 0; }
a.row:hover { background: #FAF9F6; }
.row-head { font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--stone); background: #FAF9F6; }
.row-id { font-weight: 600; color: var(--ink-soft); font-size: .85rem; }
.row-main strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span, .row-sub { display: block; font-size: .82rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main .badge { display: inline-block; margin-top: 4px; }
.row-time { font-size: .8rem; color: var(--ink-soft); }
.rows-empty { padding: 48px 20px; text-align: center; color: var(--ink-soft); }
.people .row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 110px 90px minmax(0, 1.6fr); }

/* Request detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.detail-side { display: grid; gap: 20px; position: sticky; top: 88px; }
.facts { margin: 0; display: grid; gap: 14px; }
.facts div { display: grid; gap: 2px; }
.facts dt { font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--stone); }
.facts dd { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.facts a { font-weight: 500; }
.original { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; color: #2a2a2e; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: .2rem .65rem; border-radius: 999px; background: var(--paper); font-size: .78rem; font-weight: 500; }

/* Thread */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.thread-empty { margin: 0 0 1rem; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 14px; background: var(--paper); }
.msg.mine { justify-self: end; background: var(--obsidian); color: var(--paper); }
.msg.mine .msg-meta { color: rgba(246, 244, 240, .6); }
.msg.note { justify-self: stretch; max-width: none; background: #FFF8E8; color: var(--obsidian); border: 1px dashed #E5C98F; }
.msg.note .msg-meta { color: var(--ink-soft); }
.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .3rem; font-size: .75rem; color: var(--ink-soft); }
.msg-meta time { margin-left: auto; }
.msg-body { overflow-wrap: anywhere; font-size: .93rem; }
.msg-event { text-align: center; font-size: .78rem; color: var(--ink-soft); }
.msg-event span { font-weight: 600; }
.reply { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line-light); }
.reply textarea { width: 100%; min-height: 96px; padding: .8rem 1rem; font: inherit; font-size: .95rem; background: var(--paper); border: 1px solid transparent; border-radius: 10px; resize: vertical; }
.reply textarea:focus { outline: none; background: #fff; border-color: var(--obsidian); }
.reply.is-note textarea { background: #FFF8E8; }
.reply-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper); }
.seg button { padding: .45rem .9rem; border: 0; border-radius: 999px; background: transparent; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.seg button.on { background: #fff; color: var(--obsidian); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.btn-danger { background: transparent; color: #B3261E; border-color: rgba(179, 38, 30, .35); }
.btn-danger:hover { background: #B3261E; color: #fff; }
.btn-line { background: #fff; color: var(--obsidian); border-color: var(--line-light); }
.btn-line:hover { border-color: var(--obsidian); }
.btn-xs { min-height: 32px; padding: .4rem .75rem; font-size: .64rem; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* Content editor */
.editor-bar {
  position: sticky; top: 64px; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 20px; padding: 12px 16px;
  background: rgba(239, 236, 230, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-light); border-radius: var(--radius);
}
.editor-bar .status { font-size: .85rem; color: var(--ink-soft); }
.editor-bar .status.dirty { color: #7A5200; font-weight: 600; }
.editor-section { background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); margin-bottom: 14px; }
.editor-section > summary { list-style: none; cursor: pointer; padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.editor-section > summary::-webkit-details-marker { display: none; }
.editor-section > summary::after { content: "+"; font-size: 1.3rem; font-weight: 300; color: var(--ink-soft); }
.editor-section[open] > summary::after { content: "–"; }
.editor-section > summary strong { font-weight: 600; }
.editor-section > summary span { display: block; font-size: .8rem; color: var(--ink-soft); font-weight: 400; }
.editor-body { padding: 4px 22px 22px; }
.list-editor { display: grid; gap: 12px; margin-bottom: 18px; }
.list-item { padding: 16px; border-radius: 12px; background: var(--paper); }
.list-item .field input, .list-item .field textarea { background: #fff; }
.list-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line-light); border-radius: 8px; background: #fff; cursor: pointer; font-size: .85rem; }
.icon-btn:hover { border-color: var(--obsidian); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* Account (customer) */
.tabs { display: flex; gap: 6px; margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: .6rem 1.1rem; border-radius: 999px; font-size: .85rem; font-weight: 600; text-decoration: none; white-space: nowrap; color: var(--slate); background: #fff; border: 1px solid var(--line-light); }
.tabs a.active { background: var(--obsidian); color: var(--paper); border-color: var(--obsidian); }
.account-wrap { max-width: 1040px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) var(--gutter); }
.req-cards { display: grid; gap: 12px; }
.req-card { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 18px 20px; background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); text-decoration: none; transition: border-color .2s; }
.req-card:hover { border-color: var(--obsidian); }
.req-card strong { font-weight: 600; }
.req-card .row-sub { white-space: normal; }
.req-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.empty { padding: 56px 24px; text-align: center; background: #fff; border: 1px dashed var(--line-light); border-radius: var(--radius); }
.empty h2 { font-size: 1.2rem; margin-bottom: .5rem; }
.empty p { color: var(--ink-soft); }

/* Modal */
dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(11, 11, 13, .55); }
dialog form { padding: 28px; }
dialog h2 { font-size: 1.2rem; margin-bottom: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Toasts */
#toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: .8rem 1.2rem; border-radius: 10px; background: var(--obsidian); color: var(--paper); font-size: .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: opacity .3s, transform .3s; }
.toast-error { background: #8C1D18; }
.toast.out { opacity: 0; transform: translateY(8px); }

.loading { padding: 48px; text-align: center; color: var(--ink-soft); }

/* ---------- Tablet ---------- */
@media (max-width: 1080px) {
  .detail { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { min-height: auto; padding: 28px var(--gutter); gap: 1.5rem; }
  .auth-side .auth-copy p, .auth-side .tagline { display: none; }
  .auth-side h1 { font-size: 1.4rem; }
  .auth-main { align-items: start; padding-top: 32px; }

  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 8px var(--gutter); border-right: 0; border-bottom: 1px solid var(--line-light); position: sticky; top: 64px; z-index: 30; }
  .sidebar nav { position: static; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .side-link { white-space: nowrap; padding: .55rem .8rem; font-size: .85rem; }
  .side-label { display: none; }
  .editor-bar { top: 118px; }
  .panel-grid { grid-template-columns: 1fr; }
}

/* ---------- Phone ---------- */
@media (max-width: 680px) {
  .topbar-user span:last-child { display: none; }
  .row, .people .row { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .row-head { display: none; }
  .row .row-id { display: none; }
  .row .row-time { grid-column: 1; }
  .row > :last-child { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .people .row > .hide-sm { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.6rem; }
  .msg { max-width: 100%; }
  .req-card { grid-template-columns: 1fr; }
  .req-card-side { flex-direction: row; align-items: center; }
  .actions { justify-content: flex-start; }
}

/* Receipts */
.btn-block { width: 100%; }
.receipt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.receipt-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--paper); }
.receipt-list a { text-decoration: none; min-width: 0; }
.receipt-list a strong { display: block; font-size: .88rem; }
.receipt-list a span { display: block; font-size: .78rem; color: var(--ink-soft); }
.receipt-list a:hover strong { text-decoration: underline; }
.receipt-list-side { display: flex; align-items: center; gap: 6px; flex: none; }
.receipts-table .row { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.4fr) 120px minmax(0, 1fr) 80px; }

.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 130px 130px 32px; gap: 8px; align-items: center; }
.items-head { font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--stone); margin-bottom: 6px; }
.items-head span:nth-child(n+2):nth-child(-n+4) { text-align: right; }
#items { display: grid; gap: 8px; margin-bottom: 14px; }
.item-row input { width: 100%; padding: .7rem .8rem; font: inherit; font-size: .92rem; background: var(--paper); border: 1px solid transparent; border-radius: 10px; }
.item-row input:focus { outline: none; background: #fff; border-color: var(--obsidian); }
.item-row input[data-k="qty"], .item-row input[data-k="unit"] { text-align: right; }
.item-amount { text-align: right; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.totals { margin: 0 0 8px; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; font-size: .92rem; }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; font-weight: 500; }
.totals .grand { margin-top: 6px; padding-top: 10px; border-top: 2px solid var(--obsidian); font-size: 1.1rem; }
.totals .grand dt { color: var(--obsidian); font-weight: 600; }
.totals .grand dd { font-weight: 700; }
.receipt-form .panel-grid { margin-top: 20px; }

@media (max-width: 680px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 32px; padding: 10px; border-radius: 12px; background: #FAF9F6; }
  .item-row input[data-k="description"] { grid-column: 1 / -1; }
  .item-row .item-amount { grid-column: 1 / 3; text-align: left; }
  .item-row [data-remove] { grid-column: 3; grid-row: 2; }
  .item-row input[data-k="qty"] { grid-column: 1; grid-row: 2; }
  .item-row input[data-k="unit"] { grid-column: 2; grid-row: 2; }
  .receipts-table .row { grid-template-columns: 1fr auto; }
}

/* Project names + live chat */
.ref { color: var(--stone); font-weight: 500; font-variant-numeric: tabular-nums; }
.row-strong { font-weight: 600; color: var(--obsidian) !important; }
.title-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.title-row .icon-btn { width: 32px; height: 32px; font-size: .95rem; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #2E9E5B; vertical-align: 1px; box-shadow: 0 0 0 0 rgba(46, 158, 91, .5); animation: live-pulse 2s infinite; }
.live-off .live-dot { background: var(--stone); animation: none; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 6px rgba(46, 158, 91, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 158, 91, 0); } }
.thread { max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.thread li.just-in { animation: just-in .4s ease-out; }
@keyframes just-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .live-dot, .thread li.just-in { animation: none; } }

/* Positions (Owner, Manager, Worker…) */
.badge-position { background: #F3E9D7; color: #6B4E16; }
.msg-position { padding: .05rem .45rem; border-radius: 999px; background: rgba(201, 169, 107, .22); color: inherit; font-size: .68rem; font-weight: 600; }
.msg.mine .msg-position { background: rgba(201, 169, 107, .3); color: var(--sand); }
.people .row > .row-main.hide-sm { flex-direction: row; flex-wrap: wrap; gap: 4px; display: flex; align-items: center; }
dialog { width: min(560px, calc(100vw - 32px)); }

/* Emails */
.notice { margin: 0 0 16px; padding: 12px 16px; border-radius: 10px; background: #FFF8E8; border: 1px solid #F0DDB0; font-size: .88rem; color: #5C4410; }
.notice code { background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px; }
.email-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.email-preview { position: sticky; top: 88px; }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
#preview { width: 100%; height: 720px; border: 1px solid var(--line-light); border-radius: 10px; background: #EFECE6; }
.recipient-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.recipient-tools input { flex: 1; min-width: 0; padding: .6rem .8rem; font: inherit; font-size: .9rem; background: var(--paper); border: 1px solid transparent; border-radius: 10px; }
.recipient-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line-light); border-radius: 10px; }
.recipient { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--line-light); cursor: pointer; font-size: .88rem; }
.recipient:first-child { border-top: 0; }
.recipient:hover { background: #FAF9F6; }
.recipient input { margin-top: 3px; accent-color: var(--obsidian); }
.ai-box { margin: 0 0 18px; padding: 14px; border-radius: 12px; background: linear-gradient(135deg, #FFF8E8, #F6F4F0); border: 1px solid #F0DDB0; }
.ai-box textarea { background: #fff !important; }
#ai-status { margin-left: 8px; }
.error-text { color: #8C1D18 !important; }
.emails-table .row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) 120px 150px 90px; }
@media (max-width: 1080px) {
  .email-grid { grid-template-columns: 1fr; }
  .email-preview { position: static; }
  #preview { height: 560px; }
}
@media (max-width: 680px) { .emails-table .row { grid-template-columns: 1fr auto; } }

/* Continue with Google / Apple */
.social { display: grid; gap: 10px; margin-bottom: 18px; }
.btn-social {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: .85rem 1rem; border-radius: 999px; font-weight: 600; font-size: .92rem; text-decoration: none;
  transition: background .2s, border-color .2s, transform .2s;
}
.btn-social:hover { transform: translateY(-1px); }
.btn-google { background: #fff; color: #1F1F1F; border: 1px solid #DADCE0; }
.btn-google:hover { background: #F8F9FA; border-color: #C4C7C5; }
.btn-apple { background: #000; color: #fff; border: 1px solid #000; }
.btn-apple:hover { background: #1A1A1A; }
.or { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: .75rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .14em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-light); }

/* Products */
.catalog { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.catalog > * { min-width: 0; }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-light); }
.cat-row:first-child { border-top: 0; }
.cat-row.cat-sub { padding-left: 18px; position: relative; }
.cat-row.cat-sub::before { content: "›"; position: absolute; left: 4px; color: var(--stone); }
.cat-name { min-width: 0; }
.cat-name strong { font-weight: 600; }
.cat-sub .cat-name strong { font-weight: 500; }
.cat-row .actions { flex-wrap: nowrap; }
.cat-row .icon-btn { width: 26px; height: 26px; }
.product-row { grid-template-columns: 56px minmax(0, 2fr) minmax(0, 1fr) auto; }
.product-thumb { display: grid; place-items: center; width: 56px; height: 40px; border-radius: 8px; overflow: hidden; background: var(--obsidian); color: var(--paper); }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-thumb svg { width: 60%; }
.product-thumb.big { width: 160px; height: 100px; border-radius: 10px; flex: none; }
.product-thumb.big svg { width: 40%; }
.image-pick { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.image-actions { display: grid; gap: 6px; justify-items: start; }
.image-actions small { font-size: .78rem; color: var(--ink-soft); }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
dialog.wide { width: min(720px, calc(100vw - 32px)); }

/* Customer account: Our products */
.account-wrap .products-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.account-wrap .product-foot .actions { flex-wrap: nowrap; }
.filter-chip.sub { font-size: .78rem; padding: .4rem .85rem; opacity: .85; }
.filter-chip.sub::before { content: "› "; }

/* Workers on a project */
.worker-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.worker-list li { display: flex; align-items: center; gap: 10px; }
.worker-list li > span:last-child { display: grid; line-height: 1.3; }
.avatar.sm { width: 30px; height: 30px; font-size: .7rem; flex: none; }
.pick-list { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; margin-bottom: 18px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-light); border-radius: 10px; cursor: pointer; }
.pick:hover { background: #FAF9F6; }
.pick input { accent-color: var(--obsidian); width: 16px; height: 16px; }
.badge-role-worker { background: #E4EEF6; color: #1F4A6B; }

/* WhatsApp */
.btn-whatsapp { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #25D366; color: #0B2B17; border-color: #25D366; }
.btn-whatsapp:hover { background: #1EBE5A; border-color: #1EBE5A; }
.ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ai-row select { padding: .5rem .7rem; font: inherit; font-size: .85rem; border: 1px solid var(--line-light); border-radius: 999px; background: #fff; }
.wa-screen { background: #EFE7DD; border-radius: 12px; padding: 18px; min-height: 220px;
  background-image: radial-gradient(rgba(0, 0, 0, .04) 1px, transparent 1px); background-size: 14px 14px; }
.wa-screen.small { min-height: 0; padding: 14px; }
.wa-bubble { position: relative; max-width: 92%; margin-left: auto; padding: 8px 12px 10px; border-radius: 10px 0 10px 10px; background: #D9FDD3;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .12); font-size: .9rem; line-height: 1.45; color: #111B21; word-wrap: break-word; }
.wa-list { list-style: none; margin: 0; padding: 0; }
.wa-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-light); }
.wa-list li:first-child { border-top: 0; }
.wa-person { display: grid; flex: 1; min-width: 0; }
.wa-state { flex: none; }

/* On / off switches (Website content → Page sections) */
.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-light); cursor: pointer; font-weight: 500; }
.switch-row:first-of-type { border-top: 0; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: #D4D1CB; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch-row input:checked + .switch { background: var(--obsidian); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch-row input:disabled + .switch { opacity: .5; }
.switch-row input:disabled ~ span { cursor: default; }
.switch-state { margin-left: auto; font-size: .78rem; color: var(--ink-soft); }

@media (max-width: 980px) {
  .catalog { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .product-row { grid-template-columns: 56px minmax(0, 1fr); }
  .product-row > .hide-sm { display: none; }
  .product-row > .actions { grid-column: 1 / -1; }
}

/* Workers: "Finished" heading on My projects */
.section-title { font-size: 1rem; font-weight: 600; margin: 28px 0 12px; color: var(--ink-soft); }

/* Support team accounts and approvals */
.badge-role-support { background: #E3F2EA; color: #1D5B3A; }
.badge-pending { background: #FFF3D6; color: #6B4A00; }
.pending-panel { border-color: rgba(201, 169, 107, .55); background: #FFFBF2; margin-bottom: 18px; }
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-light); }
.pending-row:first-of-type { border-top: 0; }
.pending-row .row-main { display: grid; gap: 2px; min-width: 0; }
.pending-row .row-main span { color: var(--ink-soft); font-size: .85rem; overflow-wrap: anywhere; }
.pending-row .actions { display: flex; gap: 8px; flex: none; }
@media (max-width: 680px) { .pending-row { flex-direction: column; align-items: flex-start; } }

/* Messages (js/chats.js): chat list on the left, the open chat on the right */
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-layout { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
.chat-list { display: grid; gap: 4px; max-height: 72vh; overflow-y: auto; padding: 6px; background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); }
.chat-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; text-decoration: none; color: inherit; }
.chat-item:hover { background: #FAF9F6; }
.chat-item.active { background: var(--paper); }
.chat-item-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.chat-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-item-top strong { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-top time { flex: none; font-size: .72rem; color: var(--ink-soft); }
.chat-item-sub { font-size: .8rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.unread .chat-item-sub { color: var(--obsidian); font-weight: 600; }
.chat-item .count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--obsidian); font-size: .72rem; font-weight: 700; text-align: center; line-height: 22px; }
.chat-avatar.group { background: var(--obsidian); color: var(--paper); }
.chat-none { padding: 24px 12px; text-align: center; }
.chat-pane { min-height: 360px; }
.chat-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.chat-head .panel-title { margin-bottom: .2rem; }
.chat-back { display: none; width: 100%; margin: 0; }
.chat-pick { display: grid; place-items: center; min-height: 300px; text-align: center; }
.chat-older { margin: 0 0 10px; text-align: center; }
.chat-thread { max-height: 55vh; }
.pick-person { width: 100%; font: inherit; text-align: left; background: #fff; color: inherit; }
.pick-person > span:last-child, .pick > span:last-child { display: grid; line-height: 1.3; min-width: 0; }
.pick-label { margin: 10px 2px 2px; font-size: .64rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--stone); }
dialog.chat-dialog { width: min(560px, calc(100vw - 32px)); }
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout.has-open .chat-list { display: none; }
  .chat-back { display: inline-block; }
}
.tabs a .count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--obsidian); font-size: .7rem; font-weight: 700; text-align: center; line-height: 20px; }
.tabs a[hidden], .tabs a .count[hidden] { display: none; }
