/* ═══════════════════════════════════════════════════════════
   MIR.MD — Complete Stylesheet
   Mobile-first. No !important hacks. Clean structure.
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --primary:   #006699;
  --secondary: #00b4b4;
  --success:   #27ae60;
  --danger:    #e53e3e;
  --warning:   #f59e0b;
  --surface:   #ffffff;
  --bg:        #f0f4f8;
  --border:    #e2e8f0;
  --text:      #1a2332;
  --muted:     #6b7a8d;
  --shadow:    0 2px 12px rgba(0,102,153,0.10);
  --radius:    10px;
  --radius-sm: 6px;
  --sidebar-w: 240px;
  --topbar-h:  60px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
img, svg { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Layout ──────────────────────────────────────────────── */
.app-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #003d5c 0%, #006699 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1), width 0.25s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 60px;
}
.sidebar-logo a { display:flex; align-items:center; gap:10px; text-decoration:none; flex:1; min-width:0; }
.sidebar-logo img {
  width: 38px; height: 38px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.sidebar-logo span { color: white; font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { list-style: none; flex: 1; padding: 8px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  color: rgba(255,255,255,0.78);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
}
.sidebar-nav a:hover  { background: rgba(255,255,255,0.10); color: white; }
.sidebar-nav a.active { background: rgba(255,255,255,0.15); color: white; border-left-color: var(--secondary); }
.sidebar-nav svg { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,0.1); overflow: hidden; }
.btn-logout {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: rgba(255,255,255,0.08); border: none;
  color: rgba(255,255,255,0.78); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.875rem; transition: background 0.15s;
  white-space: nowrap; text-decoration: none;
  overflow: hidden; max-width: 100%;
}
.btn-logout:hover { background: rgba(255,255,255,0.15); color: white; }
.btn-logout svg { fill: currentColor; flex-shrink:0; width:20px; height:20px; }
.btn-logout .sidebar-label { overflow: hidden; text-overflow: ellipsis; }

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s cubic-bezier(.4,0,.2,1);
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: 6px;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
}
.menu-toggle svg { fill: currentColor; }
.topbar-title { font-weight: 700; font-size: 1.05rem; color: var(--primary); flex: 1; }
.topbar-right { color: var(--muted); font-size: 0.85rem; }

main.content { flex: 1; padding: 24px 24px 48px; }

/* ── Section header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-title { font-size: 1.4rem; font-weight: 800; color: var(--text); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px; flex-wrap: wrap;
}
.card-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon { width:48px; height:48px; border-radius:12px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.stat-icon svg { width:24px; height:24px; fill:white; }
.stat-icon.blue   { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.stat-icon.green  { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.875rem;
  cursor: pointer; border: 2px solid transparent;
  transition: all 0.15s; text-decoration: none;
  white-space: nowrap;
}
.btn svg { width:15px; height:15px; fill:currentColor; flex-shrink:0; }
.btn-primary  { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover  { background: #005580; border-color: #005580; }
.btn-success  { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover  { background: #219150; border-color: #219150; }
.btn-danger   { background: var(--danger);  color: white; border-color: var(--danger); }
.btn-danger:hover   { background: #c0392b; border-color: #c0392b; }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover  { border-color: var(--primary); color: var(--primary); background: rgba(0,102,153,0.04); }
.btn-sm  { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 22px; font-size: 0.95rem; }

/* ── Action rows ─────────────────────────────────────────── */
.action-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 20px 0;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-size: 0.75rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s; font-size: 0.9rem;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* Compact input for cg-cell / inline forms */
.flabel { display:block; font-size:0.68rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; margin-bottom:3px; }
.finput { display:block; width:100%; padding:6px 10px; font-size:0.875rem; border:1.5px solid var(--border); border-radius:5px; background:var(--surface); color:var(--text); transition:border-color .15s; }
.finput:focus { outline:none; border-color:var(--primary); }

/* ── 3-col client grid ───────────────────────────────────── */
.client-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.cg-cell { padding: 10px 14px; border-right:1px solid var(--border); border-bottom:1px solid var(--border); }
.cg-cell:nth-child(3n) { border-right:none; }
.cg-cell:nth-last-child(-n+3) { border-bottom:none; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width:100%; border-collapse: collapse; min-width: 500px; }
th { padding:12px 14px; text-align:left; font-size:0.75rem; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); border-bottom:2px solid var(--border); white-space:nowrap; }
td { padding:12px 14px; border-bottom:1px solid var(--border); font-size:0.9rem; }
tbody tr:hover { background: rgba(0,102,153,0.03); }
tbody tr:last-child td { border-bottom:none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display:inline-block; padding:3px 10px; border-radius:20px; font-size:0.75rem; font-weight:700; }
.badge-draft   { background:#edf2f7; color:#4a5568; }
.badge-sent    { background:#ebf8ff; color:#2b6cb0; }
.badge-paid    { background:#f0fff4; color:#276749; }
.badge-overdue { background:#fff5f5; color:#c53030; }

/* ── Icon buttons ────────────────────────────────────────── */
.btn-icon { display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:var(--radius-sm);border:none;cursor:pointer;transition:all .15s;text-decoration:none;padding:0;flex-shrink:0; }
.btn-icon svg { width:16px;height:16px;fill:currentColor; }
.btn-icon-view   { background:var(--bg);color:var(--primary);border:1.5px solid var(--border); }
.btn-icon-view:hover   { background:var(--primary);color:white;border-color:var(--primary); }
.btn-icon-edit   { background:#fff7ed;color:#c2693d;border:1.5px solid #f5cba7; }
.btn-icon-edit:hover   { background:#c2693d;color:white;border-color:#c2693d; }
.btn-icon-delete { background:#fff0f0;color:var(--danger);border:1.5px solid #f5c6c6; }
.btn-icon-delete:hover { background:var(--danger);color:white;border-color:var(--danger); }
.btn-icon-pdf    { background:var(--primary);color:white; }
.btn-icon-pdf:hover    { opacity:.85; }
.actions-cell    { display:flex;gap:6px;align-items:center; }

/* ── Misc ────────────────────────────────────────────────── */
.empty-state { text-align:center; padding:48px 20px; color:var(--muted); }
.empty-state svg { width:48px; height:48px; fill:var(--border); margin:0 auto 16px; }
.empty-state h3 { font-size:1.1rem; margin-bottom:6px; color:var(--text); }
.flash-msg { padding:12px 18px; border-radius:var(--radius-sm); margin-bottom:16px; font-weight:500; }
.flash-success { background:#f0fff4; color:#276749; border:1px solid #9ae6b4; }
.flash-error   { background:#fff5f5; color:#c53030; border:1px solid #feb2b2; }

/* Unit select */
.unit-select { width:100%; padding:4px 4px; border:1.5px solid var(--border); border-radius:5px; font-size:0.82rem; background:var(--surface); color:var(--text); cursor:pointer; }
.unit-select:focus { border-color:var(--primary); outline:none; }

/* Total row in items table */
.total-row td { background:linear-gradient(135deg,#005580,#006699); }

/* Invoice actions */
.inv-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }

/* Sig grid */
.sig-grid { display:grid; grid-template-columns:1fr 1fr; gap:40px; margin-top:40px; padding-top:20px; border-top:1px solid var(--border); }

/* Info grid */
.info-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-bottom:28px; }

/* Filter grid */
.filter-grid { display:grid; grid-template-columns:2fr 2fr 1.5fr 2fr auto; gap:12px; align-items:end; }

/* Sidebar collapse desktop */
.sidebar-collapse-btn { margin-left:auto; background:none; border:none; color:rgba(255,255,255,.5); cursor:pointer; padding:4px; border-radius:5px; display:flex; align-items:center; flex-shrink:0; transition:color .2s; }
.sidebar-collapse-btn:hover { color:white; background:rgba(255,255,255,.1); }
.sidebar-expand-btn { display:none; width:100%; background:none; border:none; color:rgba(255,255,255,.6); cursor:pointer; padding:14px 0; justify-content:center; align-items:center; }
.sidebar-expand-btn:hover { background:rgba(255,255,255,.08); color:white; }
.sidebar-expand-btn svg { width:20px; height:20px; }
.sidebar.sidebar-collapsed { width:64px; }
.sidebar.sidebar-collapsed .sidebar-label { display:none; }
.sidebar.sidebar-collapsed .sidebar-logo { padding:18px 12px; justify-content:center; }
.sidebar.sidebar-collapsed .sidebar-collapse-btn { display:none; }
.sidebar.sidebar-collapsed .sidebar-expand-btn { display:flex; }
.sidebar.sidebar-collapsed .sidebar-nav a { padding:14px 0; justify-content:center; border-left:none; }
.sidebar.sidebar-collapsed .sidebar-nav a:hover::after { content:attr(data-label); position:absolute; left:70px; background:#1a3a4a; color:white; padding:6px 12px; border-radius:6px; font-size:.82rem; white-space:nowrap; z-index:999; box-shadow:0 4px 12px rgba(0,0,0,.3); pointer-events:none; }
.sidebar.sidebar-collapsed .sidebar-footer { padding:8px 0; justify-content:center; }
.sidebar.sidebar-collapsed .btn-logout { padding:10px; justify-content:center; }
html.sidebar-is-collapsed .sidebar { width:64px; }
html.sidebar-is-collapsed .sidebar .sidebar-label { display:none; }
html.sidebar-is-collapsed .sidebar .sidebar-logo { padding:18px 12px; justify-content:center; }
html.sidebar-is-collapsed .sidebar .sidebar-collapse-btn { display:none; }
html.sidebar-is-collapsed .sidebar .sidebar-nav a { padding:14px 0; justify-content:center; }
html.sidebar-is-collapsed .sidebar .sidebar-footer { padding:8px 0; justify-content:center; }
html.sidebar-is-collapsed .sidebar .btn-logout { padding:10px; justify-content:center; }
html.sidebar-is-collapsed .main-wrap { margin-left:64px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile-first breakpoints
   ═══════════════════════════════════════════════════════════ */

/* ── ≤ 1200px: narrow desktop ────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
}

/* ── ≤ 900px: small desktop / large tablet ───────────────── */
@media (max-width: 900px) {
  .client-grid { grid-template-columns: 1fr 1fr; }
  .cg-cell:nth-child(3n)          { border-right: 1px solid var(--border); }
  .cg-cell:nth-child(2n)          { border-right: none; }
  .cg-cell:nth-last-child(-n+3)   { border-bottom: 1px solid var(--border); }
  .cg-cell:nth-last-child(-n+2)   { border-bottom: none; }
  .cg-cell:last-child             { border-bottom: none; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}

/* ── ≤ 768px: tablet / mobile — SIDEBAR HIDDEN ───────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,0.35);
  }
  .sidebar-collapse-btn { display: none !important; }
  .sidebar-expand-btn   { display: none !important; }
  .sidebar .sidebar-label { display: inline !important; }
  .main-wrap { margin-left: 0 !important; }
  .menu-toggle { display: flex; }
  .topbar { padding: 0 14px; }
  main.content { padding: 16px 14px 40px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 14px 16px; gap: 12px; }
  .stat-value { font-size: 1.3rem; }
  .section-header { gap: 8px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .info-grid { grid-template-columns: 1fr; gap: 16px; }
  .sig-grid { grid-template-columns: 1fr; gap: 20px; }
  .filter-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* ── ≤ 640px: phone landscape ───────────────────────────── */
@media (max-width: 640px) {
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header .btn,
  .section-header > a.btn { width: 100%; justify-content: center; }
  .section-title { font-size: 1.2rem; }
  .inv-actions .btn,
  .inv-actions button,
  .inv-actions a.btn,
  .inv-actions select { flex: 1 1 140px; min-width: 0; justify-content: center; }
  .action-row { flex-direction: column; }
  .action-row .btn { width: 100%; justify-content: center; }
}

/* ── ≤ 480px: phone portrait ─────────────────────────────── */
@media (max-width: 480px) {
  main.content { padding: 12px 10px 32px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px 14px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; border-radius: 10px; }
  .stat-icon svg { width: 20px; height: 20px; }
  .stat-value { font-size: 1.2rem; }
  .card-body { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .client-grid { grid-template-columns: 1fr; }
  .cg-cell { border-right: none !important; }
  .cg-cell:last-child { border-bottom: none; }
  .topbar-title { font-size: 0.95rem; }
}

/* ── ≤ 380px: tiny phone ─────────────────────────────────── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .btn { padding: 8px 12px; font-size: 0.82rem; }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print, .action-row, .inv-actions { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  main.content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: white; }
}

/* ── invoice_new specific ────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.save-btns-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.party-stack { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.items-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Meta grid responsive */
@media (max-width: 900px)  { .meta-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px)  { .meta-grid { grid-template-columns: 1fr; } }

/* Save buttons responsive */
@media (max-width: 560px) {
  .save-btns-row { width: 100%; }
  .save-btns-row .btn { flex: 1 1 130px; justify-content: center; }
}
/* Section header save-btns row */
@media (max-width: 560px) {
  .section-header > .save-btns-row { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   Client Cards
   ═══════════════════════════════════════════════════════════ */
.client-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.client-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.client-card:hover { box-shadow: 0 4px 20px rgba(0,102,153,0.12); border-color: #b8d4e8; }
.client-card.is-default { border-color: var(--success); }

.cc-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.client-card.is-default .cc-header { background: linear-gradient(135deg, #056b3a, #2ecc71); }
/* cc-avatar removed */
.cc-title { flex: 1; min-width: 0; }
.cc-title strong { display: block; color: white; font-size: 0.9rem; line-height: 1.3; word-break: break-word; }
.cc-title .badge { margin-top: 3px; }
.cc-count { text-align: center; flex-shrink: 0; }
.cc-count span { display: block; font-size: 1.3rem; font-weight: 800; color: white; line-height: 1; }
.cc-count small { color: rgba(255,255,255,0.75); font-size: 0.7rem; }

.cc-body { padding: 12px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.cc-row { display: flex; gap: 8px; font-size: 0.84rem; }
.cc-lbl { color: var(--muted); font-weight: 600; min-width: 80px; flex-shrink: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .3px; padding-top: 1px; }
.cc-val { color: var(--text); word-break: break-word; }

.cc-footer {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ═══════════════════════════════════════════════════════════
   Mobile-responsive table cards (for small screens)
   Instead of horizontal scroll, show data as stacked key-value
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Dashboard recent table */
  .dash-table thead { display: none; }
  .dash-table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 0 0 10px;
    padding: 12px 14px;
    background: var(--surface);
  }
  .dash-table td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; border: none; font-size: 0.86rem;
    gap: 8px;
  }
  .dash-table td::before {
    content: attr(data-label);
    font-size: 0.73rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px;
    flex-shrink: 0;
  }
  .dash-table td:last-child { padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; justify-content: flex-end; }
  .dash-table td:last-child::before { display: none; }

  /* Invoices table */
  .inv-table thead { display: none; }
  .inv-table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 0 0 10px;
    padding: 12px 14px;
    background: var(--surface);
  }
  .inv-table td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; border: none; font-size: 0.86rem; gap: 8px;
  }
  .inv-table td::before {
    content: attr(data-label);
    font-size: 0.73rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px; flex-shrink: 0;
  }
  .inv-table td.no-label::before { display: none; }
  .inv-table td.no-label { justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }

  /* Catalogue table */
  .catalogue-table thead { display: none; }
  .catalogue-table tr {
    display: block; border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin: 0 0 10px; padding: 12px 14px; background: var(--surface);
  }
  .catalogue-table td { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border: none; font-size: 0.86rem; gap: 8px; }
  .catalogue-table td::before { content: attr(data-label); font-size: 0.73rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; flex-shrink: 0; }
  .catalogue-table td.no-label::before { display: none; }
  .catalogue-table td.no-label { justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }

  /* Items table in invoice_new: show as stacked rows */
  .items-table thead { display: none; }
  .items-table tr.item-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: 12px;
    padding: 12px; background: var(--surface);
  }
  .items-table tr.item-row td { display: block; padding: 0; border: none; font-size: 0.875rem; }
  .items-table tr.item-row td:first-child { display: none; } /* hide row number */
  .items-table tr.item-row td:nth-child(2) { grid-column: 1 / -1; } /* description full width */
  .items-table tr.item-row td:last-child { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
  .items-table tfoot td { display: block; text-align: right !important; }
  .items-table tfoot tr:first-child td:first-child { display: none; }
  .items-table .total-row { display: block; border-radius: var(--radius-sm); overflow: hidden; }

  /* Remove table min-width on mobile card display */
  .dash-table, .inv-table, .catalogue-table { min-width: 0 !important; }
  .table-wrap { overflow-x: visible; }
}

/* Catalogue + Invoice list: mobile-specific table header labels */
@media (min-width: 641px) {
  /* Keep tables normal on wider screens */
  .dash-table,
  .inv-table,
  .catalogue-table { min-width: 500px; }
}

/* ═══════════════════════════════════════════════════════════
   Items table — responsive dual view
   ═══════════════════════════════════════════════════════════ */

/* Desktop: show table, hide mobile cards */
.items-table-desktop   { display: block; }
.items-mobile-list     { display: none; }
.items-mobile-total    { display: none; }
.inv-table-desktop     { display: block; }
.inv-items-mobile      { display: none; }

/* Mobile: hide table, show cards */
@media (max-width: 640px) {
  .items-table-desktop { display: none; }
  .inv-table-desktop   { display: none; }

  .inv-items-mobile    { display: block; }

  .items-mobile-list {
    display: block;
    padding: 12px;
  }
  .items-mobile-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #005580, #006699);
    color: white;
    font-weight: 900;
    font-size: 1.1rem;
    padding: 14px 16px;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  /* Mobile item card */
  .mobile-item-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
  }
  .mobile-item-card .mic-desc {
    font-weight: 600; font-size: 0.95rem;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 10px;
  }
  .mobile-item-card .mic-desc input {
    flex: 1; padding: 6px 10px;
    border: 1.5px solid var(--border); border-radius: 5px;
    font-size: 0.875rem;
  }
  .mobile-item-card .mic-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  }
  .mobile-item-card .mic-field label {
    font-size: 0.66rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px;
    display: block; margin-bottom: 3px;
  }
  .mobile-item-card .mic-field input,
  .mobile-item-card .mic-field select {
    width: 100%; padding: 6px 8px;
    border: 1.5px solid var(--border); border-radius: 5px;
    font-size: 0.875rem; text-align: right;
  }
  .mobile-item-card .mic-field select { text-align: left; }
  .mobile-item-card .mic-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .mobile-item-card .mic-total {
    font-weight: 800; font-size: 1.05rem; color: var(--primary);
  }
}

/* Delete row button */
.btn-del-row {
  width: 28px; height: 28px;
  border: none; border-radius: 50%;
  background: #fff0f0; color: var(--danger);
  cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.btn-del-row:hover { background: var(--danger); color: white; }

/* Invoice info-grid on mobile */
@media (max-width: 640px) {
  .inv-items-wrap > div:last-child {
    border-radius: var(--radius-sm) !important;
  }
}

/* ══════════════════════════════════════════════
   LOGIN PAGE (index.php)
   ══════════════════════════════════════════════ */
body.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #003d5c 0%, #006699 40%, #00b4b4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 32px;
}
.logo-wrap img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 16px rgba(0,102,153,0.25));
}
.logo-wrap h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 14px;
  letter-spacing: -0.5px;
}
.logo-wrap p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}
.btn-login {
  width: 100%;
  padding: 16px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-login:hover  { opacity: 0.9; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.error-msg {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 24px 0;
}
.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}
@media (max-width: 480px) {
  .login-card { padding: 32px 22px; border-radius: 12px; }
  body.login-page { padding: 14px; align-items: flex-start; padding-top: 40px; }
}

/* ══════════════════════════════════════════════
   INVOICE VIEW extra responsive
   ══════════════════════════════════════════════ */
@media (max-width: 600px) {
  .info-grid { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════════════
   INVOICES LIST extra responsive
   ══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .filter-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 600px) {
  .filter-grid { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════════════
   ADDITIONAL UTILITY CLASSES
   ══════════════════════════════════════════════ */
.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

/* ══════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════ */
.text-muted   { color: var(--muted); font-size: 0.9rem; }
.mb-24        { margin-bottom: 24px; }
.code-badge   { font-family: monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; }
.form-inline  { display: contents; }
.login-card .error-msg.locked { background: #fff0f0; border-color: #e53e3e; }

/* ══════════════════════════════════════════════
   FREELANCER — Multi-tenant additions
   ══════════════════════════════════════════════ */

/* Subscription banner */
.sub-banner {
  padding: 10px 20px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sub-banner a { color: inherit; text-decoration: underline; }
.sub-banner-info    { background: #ebf8ff; color: #2c5282; border-color: #bee3f8; }
.sub-banner-warn    { background: #fffbeb; color: #744210; border-color: #f6e05e; }
.sub-banner-expired { background: #fff5f5; color: #742a2a; border-color: #fc8181; font-weight: 600; }

/* Auth shared (login/register/forgot/reset) */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.oauth-btns { display: flex; flex-direction: column; gap: 8px; }
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 8px;
  background: white; color: #2d3748; font-weight: 600; font-size: 0.92rem;
  text-decoration: none; cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.btn-oauth:hover { background: #f7fafc; border-color: #cbd5e0; }
.btn-oauth:active { transform: translateY(1px); }
.btn-facebook svg { color: #1877F2; }

.auth-links {
  text-align: center;
  margin-top: 18px;
  font-size: 0.88rem;
  color: var(--muted);
}
.auth-links a { color: var(--primary); text-decoration: none; margin: 0 6px; }
.auth-links a:hover { text-decoration: underline; }

/* Admin layout */
.admin-body .sidebar { background: linear-gradient(180deg, #1a202c, #2d3748); }
.admin-body .sidebar-nav a { color: rgba(255,255,255,.85); }
.admin-body .sidebar-nav a:hover,
.admin-body .sidebar-nav a.active { background: rgba(255,255,255,.1); color: white; }
.admin-body .sidebar-logo { border-bottom-color: rgba(255,255,255,.1); }
.admin-body .sidebar-logo .sidebar-label { color: white; font-weight: 700; }
.admin-body .btn-logout { color: rgba(255,255,255,.7); }

/* Responsive admin grid */
@media (max-width: 900px) {
  .adm-grid { grid-template-columns: 1fr !important; }
}

/* Default logo background helper */
.sidebar-logo img { background: white; }

/* Top-right language switcher on public pages */
.lang-switcher-top {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
}
.lang-switcher-top select {
  padding: 6px 10px;
  background: rgba(255,255,255,0.92);
  color: #2d3748;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

/* ──────────── LANGUAGE SEGMENTED CONTROL ──────────── */
.lang-seg {
  display: inline-flex;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.lang-seg a {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  border-radius: 5px;
  letter-spacing: 0.6px;
  line-height: 1;
  transition: background 120ms, color 120ms;
}
.lang-seg a:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.lang-seg a.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Variant for the auth/login card (lives inside a white card on a blue gradient page) */
.login-card .lang-seg {
  margin: 0 auto 14px;
  background: rgba(0,102,153,0.08);
}
.login-card .lang-seg-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

/* Old floating switcher — remove its visual presence */
.lang-switcher-top { display: none !important; }

/* ──────────── FLASH TOAST (always visible regardless of scroll) ──────────── */
.flash-msg {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  max-width: 420px;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 8px 28px rgba(0,0,0,0.15);
  animation: flashIn 220ms cubic-bezier(.2,.9,.2,1);
  border: 1px solid;
  transition: opacity 600ms;
}
.flash-msg.flash-success { background:#f0fff4; border-color:#9ae6b4; color:#22543d; }
.flash-msg.flash-error,
.flash-msg.flash-info    { background:#fff5f5; border-color:#fc8181; color:#742a2a; }
@keyframes flashIn {
  from { transform: translateY(-12px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}
@media (max-width: 540px) {
  .flash-msg { left: 12px; right: 12px; max-width: none; top: 12px; }
}

/* ──────────── SENDING OVERLAY (Save & Send loading state) ──────────── */
#sendingOverlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
  animation: flashIn 180ms ease-out;
}
#sendingOverlay .sending-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  min-width: 220px;
}
#sendingOverlay .spinner {
  width: 36px; height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
#sendingOverlay .sending-text {
  font-weight: 600; color: var(--text); font-size: 0.95rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ──────────── SMTP mode chooser (settings page) ──────────── */
.smtp-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) {
  .smtp-mode-grid { grid-template-columns: 1fr; }
}
.smtp-mode-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  background: #fff;
  transition: border-color 120ms, background 120ms;
  display: block;
}
.smtp-mode-card:hover { border-color: var(--primary); }
.smtp-mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.smtp-mode-card.is-active {
  border-color: var(--primary);
  background: rgba(0,102,153,0.05);
}
.smtp-mode-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 6px;
}
.smtp-mode-desc {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ──────────── PWA INSTALL BANNER ──────────── */
#pwaInstallBanner {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 950;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 32px rgba(0,0,0,0.18);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  animation: flashIn 220ms ease-out;
}
/* HTML `hidden` attr beats the ID selector — needed because the ID's
   `display:flex` otherwise overrides the user-agent `[hidden]{display:none}` */
#pwaInstallBanner[hidden] { display: none !important; }
@media (min-width: 720px) {
  #pwaInstallBanner { left: auto; right: 24px; bottom: 24px; max-width: 460px; }
}
.pwa-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pwa-banner-text strong { font-size: .95rem; color: var(--text); }
.pwa-banner-text span   { font-size: .8rem; color: var(--muted); }
.pwa-banner-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
@media (max-width: 480px) {
  .pwa-banner-text strong { display: none; }
}

/* ──────────── COOKIE NOTICE BAR ──────────── */
#cookieNotice {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 970;
  background: #1a202c;
  color: #f7fafc;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: .82rem;
  line-height: 1.4;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}
#cookieNotice[hidden] { display: none !important; }
#cookieNotice p { margin: 0; max-width: 640px; }
#cookieNotice a { color: #90cdf4; }
/* Lift the PWA install banner clear of the cookie bar when both are visible */
body.has-cookie-notice #pwaInstallBanner { bottom: 76px; }

/* Make linked stat cards behave like cards visually */
a.stat-card {
  text-decoration: none;
  color: inherit;
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
}
a.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
  border-color: var(--primary);
}

/* ──────────── COMBOBOX (searchable dropdown) ──────────── */
.combo-wrap { position: relative; display: inline-block; }
.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  margin: 0; padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  min-width: 320px;
}
.combo-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.combo-list li:hover,
.combo-list li.is-focused {
  background: rgba(0,102,153,0.07);
}
.combo-code {
  background: var(--bg);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  white-space: nowrap;
}
.combo-name { font-weight: 500; }
.combo-price { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

@media (max-width: 540px) {
  .combo-list { min-width: 0; left: -8px; right: -8px; }
  #catalogueCombo input { width: 100%; min-width: 0 !important; }
  .combo-wrap { width: 100%; display: block; }
}

/* ──────────── TICKET ATTACHMENTS ──────────── */
.ticket-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.ticket-att {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.ticket-att.att-image img {
  display: block;
  max-width: 180px;
  max-height: 140px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  transition: transform 120ms, box-shadow 120ms;
}
.ticket-att.att-image:hover img {
  transform: scale(1.02);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.ticket-att.att-video {
  max-width: 320px;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000;
}
.ticket-att.att-file {
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  border: 1px solid var(--border);
}
.ticket-att.att-file:hover { background: #fff; border-color: var(--primary); }
.ticket-att .muted { color: var(--muted); font-size: 0.78rem; margin-left: 4px; }
@media (max-width: 480px) {
  .ticket-att.att-image img,
  .ticket-att.att-video { max-width: 100%; }
}

/* ──────────── ATTACHMENT UPLOAD (preview + progress) ──────────── */
.attach-picker { margin-top: 4px; }

.attach-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.attach-card {
  position: relative;
  width: 140px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.attach-card.is-too-big { border-color: var(--danger); }
.attach-card img,
.attach-card video {
  display: block;
  width: 100%;
  height: 100px;
  object-fit: cover;
  background: #000;
}
.attach-card-icon {
  width: 100%;
  height: 100px;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  background: var(--bg);
}
.attach-card-meta {
  padding: 6px 8px;
  font-size: 0.72rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  min-height: 38px;
}
.attach-card-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.attach-card-size { color: var(--muted); }
.attach-card-size.is-too-big { color: var(--danger); font-weight: 700; }
.attach-card-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.attach-card-remove:hover { background: rgba(220,38,38,0.85); }

.attach-progress {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(0,102,153,0.06);
  border: 1px solid rgba(0,102,153,0.18);
  border-radius: 10px;
}
.attach-progress-text {
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}
.attach-progress-track {
  height: 8px;
  background: rgba(0,102,153,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.attach-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 999px;
  width: 0%;
  transition: width 120ms linear;
}

/* ──────────── ATTACHMENT CHIPS in ticket thread ──────────── */
.attach-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.attach-chip {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  display: flex;
  flex-direction: column;
  width: 180px;
}
.attach-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.10);
  border-color: var(--primary);
}
.attach-chip img,
.attach-chip-thumb {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: #f7fafc;
}
.attach-chip-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--muted);
  position: relative;
}
.attach-chip.is-video .attach-chip-thumb {
  background: linear-gradient(135deg, #1a3a4a, #0a1f2a);
  color: #fff;
}
.attach-chip.is-pdf .attach-chip-thumb {
  background: linear-gradient(135deg, #fee, #fdd);
  color: #b91c1c;
}
.attach-chip-play {
  position: absolute;
  background: rgba(255,255,255,0.85);
  color: var(--primary);
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  font-weight: bold;
  padding-left: 4px;
}
.attach-chip-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  text-align: left;
}
.attach-chip-type {
  font-weight: 700;
  color: var(--text);
}
.attach-chip-size,
.attach-chip-meta {
  color: var(--muted);
  font-size: 0.7rem;
}
.attach-chip-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* ──────────── ATTACHMENT LIGHTBOX MODAL ──────────── */
.att-lb {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 22, 0.92);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  animation: flashIn 180ms ease-out;
}
.att-lb[hidden] { display: none; }
.att-lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(135deg, #006699, #00b4b4);
  color: #fff;
  flex-shrink: 0;
}
.att-lb-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}
.att-lb-actions { display: flex; gap: 8px; }
.att-lb-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.32);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.att-lb-btn:hover { background: rgba(255,255,255,0.30); }
.att-lb-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: auto;
}
.att-lb-img,
.att-lb-video {
  max-width: min(96vw, 1600px);
  max-height: calc(100vh - 90px);
  display: block;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.att-lb-video { width: auto; background: #000; }
.att-lb-pdf {
  width: min(96vw, 1100px);
  height: calc(100vh - 90px);
  border: none;
  background: #fff;
  border-radius: 6px;
}
@media (max-width: 640px) {
  .attach-chip { width: 140px; }
  .attach-chip img, .attach-chip-thumb { height: 100px; }
  .attach-chip-thumb { font-size: 36px; }
  .att-lb-name { max-width: 40vw; font-size: 0.8rem; }
}
