:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --border: #e1e4df;
  --text: #1f2a1e;
  --muted: #6b7566;
  --accent: #4c7a3f;
  --accent-dark: #3a5e30;
  --accent-light: #e7f0e3;
  --warn: #b5651d;
  --danger: #b3261e;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

button {
  cursor: pointer;
  font-family: inherit;
}

.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}
.btn:hover { background: #f0f1ee; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn-danger:hover { background: #fdecea; }
.btn-small { padding: 4px 10px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

/* ---- Auth screens ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-box {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}
.auth-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
}
.auth-box p.sub {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 13px;
}
.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0 0;
  min-height: 16px;
}

/* ---- App shell ---- */
#view-app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: var(--accent-dark);
  color: #fff;
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 16px;
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 12px;
}
.sidebar .brand small {
  display: block;
  font-weight: 400;
  opacity: 0.75;
  font-size: 11px;
  margin-top: 2px;
}
.nav-item {
  display: block;
  padding: 10px 20px;
  color: #e7f0e3;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active {
  background: rgba(255,255,255,0.12);
  border-left-color: #fff;
  font-weight: 600;
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  font-size: 12px;
  opacity: 0.8;
}

#view-as-box {
  margin-top: auto;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
}
#view-as-box label {
  color: rgba(255,255,255,0.65);
  margin-bottom: 4px;
}
#view-as-box select {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}
#view-as-box select option {
  color: #111;
}
.view-as-banner {
  background: #fdecd8;
  color: var(--warn);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  margin-top: 8px;
  display: inline-block;
}
.main {
  flex: 1;
  padding: 28px 36px;
  max-width: 1200px;
}
.main h2 {
  margin: 0 0 4px;
  font-size: 20px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
}
.page-header p { color: var(--muted); margin: 0; font-size: 13px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: #f0f2ee;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--accent-light); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  text-decoration: underline;
  padding: 0;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent-dark);
}
.badge.supplier { background: #fdecd8; color: var(--warn); }
.badge.admin { background: #fde8e6; color: var(--danger); }
.badge.client { background: #e3edfd; color: #2f5fb0; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  width: 560px;
  max-width: 100%;
  padding: 24px;
}
.modal-wide {
  width: 720px;
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.close-x {
  float: right;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
}

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.inline-add {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.inline-add input { flex: 1; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
}
.toast.error { background: var(--danger); }

.empty-state {
  color: var(--muted);
  padding: 24px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.detail-grid .k { color: var(--muted); }
.detail-grid .v { white-space: pre-wrap; }

.bullet-list {
  margin: 0;
  padding-left: 18px;
}
.bullet-list li {
  margin: 2px 0;
}

.container-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.container-row:first-of-type { border-top: none; }
.container-index {
  font-weight: 600;
  width: 28px;
  flex-shrink: 0;
}
.container-booking {
  display: flex;
  gap: 6px;
  align-items: center;
}
.container-booking input {
  width: 140px;
}
.container-docs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.container-docs input[type="file"] {
  width: 150px;
  font-size: 12px;
  padding: 4px;
}
.doc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.new-doc-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.new-doc-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.new-doc-row input[type="text"] {
  width: 130px;
  font-size: 12px;
  padding: 4px 6px;
}
.new-doc-row input[type="file"] {
  width: 150px;
  font-size: 12px;
  padding: 4px;
}
/* ---- Client portal: language switch + product filter ---- */
.lang-toggle {
  display: flex;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  overflow: hidden;
}
.lang-toggle button {
  flex: 1;
  padding: 5px 0;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}
.lang-toggle button:hover { background: rgba(255, 255, 255, 0.1); }
.lang-toggle button.active { background: #fff; color: var(--accent-dark); font-weight: 600; cursor: default; }

.product-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.product-filter-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.filter-chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}
.filter-chip:hover { border-color: var(--accent); }
.filter-chip.on {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}
.filter-chip.on::before { content: "✓ "; }

/* ---- Document folders ---- */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.ok { background: var(--accent-light); color: var(--accent-dark); }
.status-pill.warn { background: #fdecd8; color: var(--warn); }
.status-pill.danger { background: #fde8e6; color: var(--danger); }
.status-pill.info { background: #e3edfd; color: #2f5fb0; }
.status-pill.muted { background: #eef0ec; color: var(--muted); }

.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e0352b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--panel);
}
.docs-summary { display: inline-flex; align-items: center; gap: 6px; }

.folder-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.folder-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(58, 94, 48, 0.14);
  transform: translateY(-1px);
}
.folder-tile-icon { position: relative; width: 34px; height: 28px; flex-shrink: 0; display: block; }
.folder-tile-icon .notif-badge { position: absolute; top: -7px; right: -9px; }
.folder-tile-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 70px; }
.folder-tile-title { font-size: 13px; font-weight: 600; }
.folder-tile-sub { font-size: 11px; color: var(--muted); }

.folder-overlay { z-index: 60; background: rgba(0, 0, 0, 0.45); }
.folder-modal { width: 760px; position: relative; }
.folder-modal.drag-over { outline: 3px dashed var(--accent); outline-offset: -8px; }
.folder-modal .drop-hint { display: none; }
.folder-modal.drag-over .drop-hint {
  display: flex;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(231, 240, 227, 0.92);
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent-dark);
  pointer-events: none;
  z-index: 2;
}
.folder-head { display: flex; align-items: center; gap: 12px; margin-right: 28px; }
.folder-head-icon { width: 46px; height: 38px; flex-shrink: 0; }
.folder-head-text { flex: 1; min-width: 0; }
.folder-head h3 { margin: 0; }
.folder-head-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.folder-banner {
  margin: 14px 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.4;
}
.folder-banner.ok { background: var(--accent-light); color: var(--accent-dark); }
.folder-banner.warn { background: #fdf3e6; color: #8a4c14; }
.folder-banner.danger { background: #fdecea; color: var(--danger); }
.folder-banner.info { background: #edf3fe; color: #2f5fb0; }
.folder-banner.muted { background: #f3f4f1; color: var(--muted); }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 10px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbf9;
  min-width: 0;
}
.file-card.uploading { opacity: 0.55; }
.file-card.flagged { border-color: #e0352b; background: #fffafa; }
.file-card.replacing { opacity: 0.6; pointer-events: none; }
.file-card.fixed { border-color: var(--accent); background: #f6faf4; }
.fixed-tag { margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--accent-dark); }
.replace-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  border-color: #e0352b;
  color: #b3261e;
  background: #fff;
}
.replace-btn:hover { background: #fdecea; }
.file-thumb {
  position: relative;
  width: 46px;
  height: 58px;
  border-radius: 5px 14px 5px 5px;
  background: #fff;
  border: 1px solid #d5d9d2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-decoration: none;
  margin-bottom: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: transform 0.12s;
}
a.file-thumb:hover { transform: translateY(-2px); }
.file-ext {
  width: 100%;
  padding: 2px 0;
  border-radius: 0 0 4px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  color: #fff;
  background: #7d8679;
}
.file-thumb.pdf .file-ext { background: #c93a2e; }
.file-thumb.sheet .file-ext { background: #2e8b57; }
.file-thumb.doc .file-ext { background: #2f5fb0; }
.file-thumb.img .file-ext { background: #8a56b8; }
.file-name, .file-name-input {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 4px; }
.file-name-input {
  padding: 2px 4px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 5px;
  text-overflow: ellipsis;
}
.file-name-input:hover { border-color: var(--border); background: #fff; }
.file-name-input:focus { border-color: var(--accent); background: #fff; outline: none; }
.file-meta {
  width: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-actions { display: flex; gap: 2px; margin-top: 6px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 7px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover { background: #e9ece6; color: var(--text); }
.icon-btn.danger:hover { background: #fdecea; color: var(--danger); }
.icon-btn-count { font-size: 11px; font-weight: 700; }
.file-add {
  justify-content: center;
  border-style: dashed;
  border-width: 2px;
  background: none;
  color: var(--muted);
  min-height: 150px;
  font-family: inherit;
}
.file-add:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-light); }
.file-add-plus { font-size: 30px; line-height: 1; font-weight: 300; }
.file-add-label { font-size: 13px; font-weight: 600; }
.file-add-hint { font-size: 11px; }

.folder-section-title {
  margin: 20px 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.doc-comments { display: flex; flex-direction: column; gap: 8px; }
.doc-comments-empty { color: var(--muted); font-size: 13px; }
.doc-comment {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.doc-comment.mine { background: #fafbf9; }
.doc-comment.open { border-left-color: #e0352b; background: #fffafa; }
.doc-comment-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.doc-comment-time { margin-left: auto; font-size: 11px; color: var(--muted); }
.doc-comment-head .comment-del { padding: 2px 5px; margin-left: 2px; }
.doc-comment-about { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.doc-comment-body { margin-top: 4px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-comment-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}
.doc-comment-divider::before, .doc-comment-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.comment-composer { margin-top: 10px; }
.comment-composer textarea { min-height: 54px; }
.comment-composer-hint { margin-top: 4px; font-size: 11px; color: var(--muted); }
.comment-composer-row { display: flex; gap: 8px; margin-top: 6px; }
.comment-composer-row select { flex: 1; min-width: 0; }
.comment-composer-row .btn { flex-shrink: 0; }
.comment-composer-row { justify-content: flex-end; }

.icon-btn { position: relative; }
.icon-btn.active { background: #e9ece6; color: var(--text); }
.notif-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e0352b;
  box-shadow: 0 0 0 2px #fafbf9;
}
.file-card.chat-open { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.file-chat {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbf9;
}
.file-chat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.file-chat-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.folder-footer-hint { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.folder-footer .btn { flex-shrink: 0; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: default; }

.column-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
}
.column-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
}
.column-row:hover { background: #f5f6f4; }
.column-row input[type="checkbox"] { width: auto; }
.column-row-label { flex: 1; font-size: 13px; }
.column-row .btn-small { padding: 2px 10px; }

.unsaved-mark {
  font-size: 11px;
  color: var(--warn);
  font-weight: 600;
}

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  padding: 14px 0;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.btn-big {
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
}
.btn-big:disabled {
  opacity: 0.5;
  cursor: default;
}

.doc-row a {
  color: var(--accent-dark);
  text-decoration: none;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: #fafbf9;
}
.position-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.position-card-header strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

td.order-ref { font-weight: 600; white-space: nowrap; }

.password-section { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border); }
.password-note { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.password-section .inline-add { margin-top: 0; }
.password-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--accent-light);
  border-radius: var(--radius);
  font-size: 13px;
}
.password-result code {
  padding: 2px 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  user-select: all;
}
.password-result .password-note { flex-basis: 100%; margin: 0; }

/* ======================================================================
   Phones and tablets
   Desktop is unchanged above this point. Below ~900px the sidebar becomes
   a top bar, tables become labelled cards, and pop-ups fill the screen.
   ====================================================================== */
.menu-toggle { display: none; }
#orders-table-wrap, #clients-table-wrap, #users-table-wrap { overflow-x: auto; }

@media (max-width: 1000px) {
  .main { padding: 22px 20px; }
}

@media (max-width: 900px) {
  /* ---- sign-in ---- */
  .auth-box { width: auto; max-width: 380px; flex: 1; margin: 16px; padding: 24px 20px; }

  /* ---- app shell: the sidebar becomes a sticky top bar ---- */
  #view-app { flex-direction: column; }
  .sidebar { width: 100%; padding: 0; position: sticky; top: 0; z-index: 40; }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; }
  .sidebar .brand { padding: 0; margin: 0; border-bottom: none; font-size: 15px; min-width: 0; }
  .sidebar .brand small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62vw; }
  .menu-toggle {
    display: inline-block;
    flex-shrink: 0;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    background: transparent;
    color: #fff;
    font-size: 13px;
  }
  .sidebar-nav { display: flex; border-top: 1px solid rgba(255, 255, 255, 0.15); }
  .nav-item { flex: 1; text-align: center; padding: 12px 8px; font-size: 14px; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-left-color: transparent; border-bottom-color: #fff; }
  .sidebar-extra { display: none; padding: 8px 14px 14px; border-top: 1px solid rgba(255, 255, 255, 0.15); }
  .sidebar.menu-open .sidebar-extra { display: block; }
  #view-as-box { margin-top: 0; padding: 8px 0 12px; border-top: none; }
  .sidebar-footer { padding: 0; margin-top: 4px; }

  /* ---- page ---- */
  .main { padding: 14px 12px 56px; max-width: 100%; min-width: 0; }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .page-header .btn { flex: 1; }
  .page-header > .btn { width: 100%; }
  .filter-chip { padding: 8px 14px; font-size: 14px; }

  /* ---- tables become cards: every cell carries its own label ---- */
  #orders-table-wrap, #clients-table-wrap, #users-table-wrap { overflow: visible; }
  table, tbody { display: block; background: transparent; border: none; border-radius: 0; }
  tr.table-head { display: none; }
  table tr {
    display: block;
    margin-bottom: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
  }
  table tr.clickable:active { background: var(--accent-light); }
  table tr:last-child td { border-bottom: 1px solid var(--border); }
  td {
    display: grid;
    grid-template-columns: minmax(84px, 34%) 1fr;
    gap: 10px;
    padding: 8px 14px;
    font-size: 14px;
    text-align: left;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 3px;
  }
  td.order-ref { background: #f0f2ee; font-size: 15px; padding: 10px 14px; }
  td.row-actions { display: flex; justify-content: flex-end; gap: 18px; }
  td.row-actions::before { display: none; }
  td.row-actions:empty { display: none; }
  table tr td:last-child { border-bottom: none; }
  td .bullet-list { padding-left: 16px; }
  td > * { justify-self: start; text-align: left; }

  /* ---- pop-ups fill the screen ---- */
  .modal-overlay { padding: 10px 8px 24px; }
  .modal, .modal-wide, .folder-modal { width: 100%; padding: 18px 14px; }
  .detail-grid { grid-template-columns: 108px 1fr; gap: 6px 10px; }
  .field-row { flex-direction: column; gap: 0; }
  .modal-actions { gap: 8px; }
  .modal-actions .btn { flex: 1; }
  .close-x { font-size: 26px; line-height: 1; padding: 2px 8px; }

  /* ---- forms and buttons sized for a thumb (16px stops iPhones zooming in on focus) ---- */
  input, select, textarea { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 10px 14px; font-size: 14px; }
  .btn-small { padding: 8px 12px; font-size: 13px; }
  .link-btn { font-size: 14px; padding: 6px 2px; }
  .icon-btn { padding: 10px 12px; }
  .inline-add { flex-wrap: wrap; }
  .toast { left: 12px; right: 12px; bottom: 12px; text-align: center; }

  /* ---- order screen: containers and their document folders ---- */
  .container-row { gap: 8px; }
  .container-docs { margin-left: 0; width: 100%; }
  .folder-tile { width: 100%; }
  .container-booking input { width: 130px; }

  /* ---- the document folder ---- */
  .folder-head { flex-wrap: wrap; row-gap: 6px; margin-right: 34px; }
  .folder-head-icon { width: 36px; height: 30px; }
  .folder-head h3 { font-size: 16px; }
  .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .file-card { padding: 12px 8px 6px; }
  .file-add { min-height: 120px; }
  .file-chat { padding: 10px; }
  .doc-comment-head { flex-wrap: wrap; }
  .comment-composer-row .btn { width: 100%; }
  .folder-footer { flex-direction: column; align-items: stretch; }
  .folder-footer .btn { width: 100%; }
  .folder-footer-hint { flex: none; }
  .new-doc-row { flex-wrap: wrap; }
  .new-doc-row input[type="text"], .new-doc-row input[type="file"] { width: 100%; }
}

/* ---------- Admin: Jarvis & Gmail ---------- */
.jarvis-card { background: #fff; border: 1px solid var(--border, #e3e6df); border-radius: 12px; padding: 16px 18px; margin-bottom: 18px; }
.jarvis-card h3 { margin: 0 0 10px; font-size: 15px; }
.jarvis-row { display: flex; align-items: baseline; gap: 8px; margin: 6px 0; font-size: 14px; }
.jarvis-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #c9cdc4; transform: translateY(-1px); }
.jarvis-dot.ok { background: #4c8a3f; }
.jarvis-note { margin: 4px 0 10px 17px; font-size: 13px; color: var(--muted, #6b7265); overflow-wrap: anywhere; }
.jarvis-note.jarvis-warn { color: #a4541a; }
.jarvis-actions { display: flex; gap: 8px; margin: 10px 0 0 17px; flex-wrap: wrap; }
.jarvis-card a.btn { display: inline-block; text-decoration: none; margin-left: 17px; }
.jarvis-actions a.btn { margin-left: 0; }

.jarvis-instructions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.jarvis-instructions label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.jarvis-hint { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.jarvis-instructions textarea { width: 100%; box-sizing: border-box; min-height: 150px; resize: vertical; font: inherit; font-size: 14px; line-height: 1.45; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); }
.jarvis-instructions textarea:focus { outline: 2px solid var(--accent-light); border-color: var(--accent); }
.jarvis-instructions-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.jarvis-instructions-foot .jarvis-hint { margin: 0; }
.jarvis-instructions-foot .btn[disabled] { opacity: 0.5; cursor: default; }
@media (max-width: 900px) { .jarvis-instructions textarea { font-size: 16px; } }
