@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --accent:      #bd382b;
  --accent-dark: #a32f24;
  --dark:        #3D3D3D;
  --mid:         #555555;
  --surface:     #ffffff;
  --bg:          #f5f5f5;
  --border:      #e0e0e0;
  --text:        #3D3D3D;
  --text-2:      #5A5A5A;
  --text-muted:  #8A8A8A;
  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      6px;
  --radius-lg:   10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

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

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.25s ease;
}

@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar__logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

.sidebar__logo-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar__logo-sub {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.04em;
}

.sidebar__nav {
  flex: 1;
  padding: 1rem 0.625rem;
  overflow-y: auto;
}

.sidebar__section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  padding: 0 0.5rem;
  margin-bottom: 0.375rem;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.575rem 0.75rem;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}

.sidebar__link:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.sidebar__link.is-active { background: rgba(189,56,43,0.25); color: #fff; }
.sidebar__link.is-active svg { color: var(--accent); }
.sidebar__link svg { flex-shrink: 0; color: rgba(255,255,255,0.35); transition: color 0.15s; }
.sidebar__link:hover svg { color: rgba(255,255,255,0.65); }

.sidebar__create-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.sidebar__create-btn:hover { background: var(--accent-dark); }

.sidebar__footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.sidebar__company { font-size: 11.5px; color: rgba(255,255,255,0.5); font-weight: 500; }
.sidebar__version  { font-size: 10.5px; color: rgba(255,255,255,0.25); margin-top: 2px; }

.sidebar__user-pill {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.sidebar__user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar__user-name { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,0.85); line-height: 1.3; }
.sidebar__user-role { font-size: 11px; color: rgba(255,255,255,0.38); }

.sidebar__link--logout { opacity: 0.65; }
.sidebar__link--logout:hover { opacity: 1; color: #fca5a5 !important; background: rgba(255,100,100,0.12) !important; }

/* ── Main wrap ───────────────────────────────────────── */
.main-wrap {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (max-width: 767px) {
  .main-wrap { margin-left: 0; }
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text);
  transition: background 0.15s;
}
.topbar__hamburger:hover { background: var(--bg); }
@media (max-width: 767px) { .topbar__hamburger { display: flex; } }

.topbar__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
  flex: 1;
}

.topbar__actions { display: flex; align-items: center; gap: 0.75rem; }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s;
  border: none;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.875rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s;
  border: none;
  cursor: pointer;
}
.btn-primary-sm:hover { background: var(--accent-dark); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  background: transparent;
  color: var(--dark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.btn-outline:hover { border-color: var(--dark); background: var(--bg); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: var(--text-2);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: #c0392b;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s;
  cursor: pointer;
  border: none;
}
.btn-danger:hover { background: #fef2f2; }

/* ── Flash ───────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  font-size: 13.5px;
  font-weight: 500;
}
.flash--success { background: #f0fdf4; color: #166534; border-bottom: 1px solid #bbf7d0; }
.flash--error   { background: #fef2f2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.flash__close   { color: inherit; opacity: 0.6; font-size: 16px; }
.flash__close:hover { opacity: 1; }

/* ── Page content ────────────────────────────────────── */
.page-content { padding: 1.75rem 1.5rem; flex: 1; }
@media (min-width: 1024px) { .page-content { padding: 2rem 2rem; } }

/* ── Dashboard hero banner ───────────────────────────── */
.dash-hero {
  margin: -1.75rem -1.5rem 1.75rem;
  padding: 1.75rem 1.5rem 1.75rem;
  background: var(--dark);
}
@media (min-width: 1024px) {
  .dash-hero { margin: -2rem -2rem 2rem; padding: 2rem 2rem 2rem; }
}

.dash-hero .stat-card {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
}
.dash-hero .stat-card__label { color: rgba(255,255,255,0.5); }
.dash-hero .stat-card__value { color: #fff; }
.dash-hero .stat-card__sub   { color: rgba(255,255,255,0.38); }
.dash-hero .stat-card--accent {
  background: rgba(189,56,43,0.22);
  border-color: rgba(189,56,43,0.35);
}
.dash-hero .stat-card--accent .stat-card__value { color: #fca5a5; }

/* ── Dashboard section label ─────────────────────────── */
.dash-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.dash-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Stats grid ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 0;
}
@media (min-width: 640px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-card__label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.stat-card__value { font-size: 26px; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-card__sub   { font-size: 12px; color: var(--text-muted); margin-top: 0.375rem; }
.stat-card--accent .stat-card__value { color: var(--accent); }

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card__title { font-size: 14px; font-weight: 700; color: var(--dark); }
.card__body  { padding: 1.25rem; }

.card__header--accent {
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: -1px -1px 0;
  border: none;
}

.card__header--dark {
  background: #f0f0f0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: -1px -1px 0;
  border-bottom: 1px solid var(--border);
}
.card__header--dark .card__title { color: var(--dark); }

/* ── Table ───────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { padding: 0.625rem 1rem; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg); }
tbody td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }

.tbl-actions { display: flex; align-items: center; gap: 0.25rem; }

/* ── Badge ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-gray  { background: #f3f4f6; color: #374151; }
.badge-blue  { background: #eff6ff; color: #1d4ed8; }
.badge-green { background: #f0fdf4; color: #15803d; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-red   { background: #fef2f2; color: #b91c1c; }

/* ── Status chip colors (trigger pill) ───────────────── */
.status-chip--draft     { background: #f3f4f6; color: #374151;  border-color: #d1d5db; }
.status-chip--sent      { background: #eff6ff; color: #1d4ed8;  border-color: #bfdbfe; }
.status-chip--deposit   { background: #fffbeb; color: #b45309;  border-color: #fcd34d; }
.status-chip--paid      { background: #f0fdf4; color: #15803d;  border-color: #bbf7d0; }
.status-chip--accepted  { background: #f0fdf4; color: #15803d;  border-color: #bbf7d0; }
.status-chip--rejected  { background: #fef2f2; color: #b91c1c;  border-color: #fecaca; }
.status-chip--delivered { background: #f0fdf4; color: #15803d;  border-color: #bbf7d0; }
.status-chip--cancelled { background: #fef2f2; color: #b91c1c;  border-color: #fecaca; }

/* ── Custom status picker ────────────────────────────── */
.status-picker { position: relative; display: inline-block; }

.status-picker__trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.3rem 0.55rem 0.3rem 0.8rem;
  border-radius: 100px;
  border: 1.5px solid transparent;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.35;
  white-space: nowrap;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.status-picker__trigger:hover { opacity: 0.78; }
.status-picker.is-open .status-picker__trigger { box-shadow: 0 0 0 3px rgba(0,0,0,0.09); opacity: 1; }
.status-picker__chevron { transition: transform 0.18s; flex-shrink: 0; }
.status-picker.is-open .status-picker__chevron { transform: rotate(180deg); }

.status-picker__menu {
  position: fixed;
  min-width: 158px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  padding: 5px;
  z-index: 9999;
  display: none;
}
.status-picker.is-open .status-picker__menu {
  display: block;
  animation: sp-in 0.13s ease;
}
@keyframes sp-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.status-picker__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.48rem 0.8rem;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.status-picker__option::before {
  content: '';
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
}
.status-picker__option.is-current::before { content: '✓'; font-size: 11px; font-weight: 800; color: var(--accent); }
.status-picker__option:hover:not(.is-disabled):not(.is-current) { background: var(--bg); }
.status-picker__option.is-current  { background: var(--bg); font-weight: 700; cursor: default; }
.status-picker__option.is-disabled { color: #9ca3af; cursor: not-allowed; pointer-events: none; text-decoration: line-through; }
.status-picker__option.is-danger   { color: #b91c1c; }
.status-picker__option.is-danger.is-current { color: #b91c1c; }

/* Form-mode picker fills its container like a normal input */
.status-picker--form { display: block; }
.status-picker--form .status-picker__trigger { width: 100%; justify-content: space-between; }
.status-picker--form .status-picker__menu    { width: 100%; }

/* ── Inline amount paid input ────────────────────────── */
.amount-paid-input {
  width: 90px; border: none; outline: none;
  background: transparent; font-size: 13.5px;
  font-weight: 600; text-align: right; color: var(--dark);
  padding: 0.15rem 0;
  border-bottom: 1.5px solid var(--border);
}
.amount-paid-input:focus { border-bottom-color: var(--accent); }
.amount-paid-input.is-locked { opacity: 0.35; cursor: not-allowed; border-bottom-style: dashed; }
.tbl-muted { color: var(--text-muted); font-size: 13px; }

/* ── Forms ───────────────────────────────────────────── */
.form-grid { display: grid; gap: 1rem; }
.form-grid--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 639px) { .form-grid--2 { grid-template-columns: 1fr; } }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 767px) { .form-grid--3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 479px) { .form-grid--3 { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--dark); }
.form-label span { color: var(--accent); }

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text);
  background: #f9f9f9;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(189,56,43,0.1); background: var(--surface); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.6; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 11.5px; color: var(--text-muted); }

/* ── Reference picker (custom combobox) ─────────────────── */
.ref-picker {
  position: relative;
}

.ref-picker__input-wrap {
  position: relative;
}

.ref-picker__search {
  width: 100%;
  padding: 0.6rem 2.25rem 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.ref-picker__search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(189,56,43,0.1);
}
.ref-picker__search::placeholder { color: var(--text-muted); }

.ref-picker__chevron {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.ref-picker.is-open .ref-picker__chevron {
  transform: translateY(-50%) rotate(180deg);
}
.ref-picker.is-open .ref-picker__search {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.ref-picker__dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}
.ref-picker.is-open .ref-picker__dropdown { display: block; }

.ref-picker__option {
  padding: 0.6rem 0.875rem;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s, color 0.1s;
}
.ref-picker__option:last-child { border-bottom: none; }
.ref-picker__option:hover { background: rgba(189,56,43,0.07); color: var(--accent); }
.ref-picker__option.is-selected {
  background: rgba(189,56,43,0.1);
  color: var(--accent);
  font-weight: 600;
}
.ref-picker__empty {
  padding: 0.875rem;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Items table (document form) ─────────────────────── */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { padding: 0.5rem 0.75rem; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border); background: var(--bg); text-align: left; }
.items-table td { padding: 0.375rem 0.375rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.items-table tbody tr:hover td { background: #fafafa; }
.items-table .col-desc { width: 45%; }
.items-table .col-qty  { width: 10%; }
.items-table .col-rate { width: 15%; }
.items-table .col-amt  { width: 15%; }
.items-table .col-del  { width: 8%; text-align: center; }

.item-input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: transparent;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.item-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px rgba(189,56,43,0.08); }
.item-input.text-right { text-align: right; }

.item-amount { font-size: 13px; color: var(--text); font-weight: 500; text-align: right; padding: 0.45rem 0.5rem; }

.btn-del-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  margin: auto;
  cursor: pointer;
  border: none;
  background: none;
}
.btn-del-row:hover { background: #fee2e2; color: #b91c1c; }

.totals-block {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  align-items: flex-end;
  padding: 1rem 0.75rem 0;
}

.totals-block .total-row {
  display: flex;
  gap: 2rem;
  font-size: 13.5px;
}

.totals-block .total-row .lbl { color: var(--text-muted); font-weight: 500; min-width: 80px; text-align: right; }
.totals-block .total-row .val { font-weight: 600; min-width: 100px; text-align: right; color: var(--dark); }
.totals-block .total-row.grand .lbl { color: var(--dark); font-weight: 700; }
.totals-block .total-row.grand .val { color: var(--accent); font-size: 15px; }
.totals-block .total-row .dn-input { border: none; background: transparent; outline: none; font-weight: 600; width: 100px; text-align: right; color: var(--dark); font-size: 13.5px; padding: 0; }
#dn-totals .lbl { min-width: 160px; }

/* ── Section heading ─────────────────────────────────── */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-head h2 { font-size: 15px; font-weight: 700; color: var(--dark); }

/* ── Filter bar ─────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-bar .form-control { max-width: 180px; padding: 0.5rem 0.75rem; }
.filter-bar input[type="search"] { max-width: 220px; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 1rem; opacity: 0.35; }
.empty-state p { font-size: 14px; margin-bottom: 1.25rem; }

/* ── Doc type chip ───────────────────────────────────── */
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.type-chip--invoice       { background: #fff7ed; color: #c2410c; }
.type-chip--quote         { background: #eff6ff; color: #1d4ed8; }
.type-chip--delivery_note { background: #f0fdf4; color: #15803d; }

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.2s;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.375rem 0;
}
.modal__title { font-size: 16px; font-weight: 700; color: var(--dark); }
.modal__close {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: border-color 0.15s, color 0.15s; cursor: pointer; background: none;
}
.modal__close:hover { border-color: var(--accent); color: var(--accent); }
.modal__body { padding: 1.25rem 1.375rem; display: flex; flex-direction: column; gap: 0.875rem; }
.modal__footer { padding: 0 1.375rem 1.375rem; display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Misc ────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-right { text-align: right; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.gap-1 { gap: 0.5rem; }

.doc-number { font-weight: 700; font-size: 13px; color: var(--dark); font-family: 'Courier New', monospace; }

/* ── Responsive table on mobile ─────────────────────── */
@media (max-width: 639px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody td { padding: 0.375rem 1rem; border-bottom: none; }
  tbody td::before { content: attr(data-label); font-size: 10.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; display: block; }
  tbody tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.75rem; background: var(--surface); }
}

/* ── Dashboard Analytics ─────────────────────────────── */
.card__hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
@media (min-width: 768px) {
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .analytics-grid { grid-template-columns: repeat(3, 1fr); }
}

.analytics-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Revenue summary numbers above chart */
/* Collections card */
.collections-rate {
  margin-bottom: 1rem;
}
.collections-rate__bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.collections-rate__fill {
  height: 100%;
  background: #22c55e;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.collections-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.125rem;
}
.collections-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12.5px;
}
.collections-item--total {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.125rem;
}
.collections-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.collections-item__lbl {
  flex: 1;
  color: var(--text-2);
}
.collections-item__val {
  font-weight: 700;
  color: var(--dark);
}

.collections-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}
.collections-meta__item { text-align: center; }
.collections-meta__val {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}
.collections-meta__lbl {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* SVG bar chart */
.bar-chart-svg {
  width: 100%;
  height: 110px;
  display: block;
}

/* Status stacked bar */
.status-stack {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--border);
  margin-bottom: 0.875rem;
  gap: 1px;
}
.status-seg {
  height: 100%;
  min-width: 3px;
  transition: opacity 0.15s;
}
.status-seg:hover { opacity: 0.8; }

.status-legend {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.status-legend__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12.5px;
}
.status-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-legend__lbl {
  flex: 1;
  color: var(--text-2);
}
.status-legend__cnt {
  font-weight: 600;
  color: var(--dark);
  font-size: 12px;
  min-width: 20px;
  text-align: right;
}

/* Quick stat items (outstanding / paid totals) */
.dash-quick-stats {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.dash-quick-stat {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.dash-quick-stat__icon {
  flex-shrink: 0;
  margin-top: 2px;
}
.dash-quick-stat__icon--warn { color: #f59e0b; }
.dash-quick-stat__icon--ok   { color: #22c55e; }
.dash-quick-stat__val {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}
.dash-quick-stat__lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Bottom grid: Calendar / Top Clients / Outstanding ── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
@media (min-width: 640px) {
  .bottom-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .bottom-grid { grid-template-columns: 240px 1fr 1fr; }
}

/* Mini calendar */
.mini-cal { padding: 1rem; }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.cal-nav__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
}
.cal-nav__btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}
.cal-nav__btn:hover { border-color: var(--accent); color: var(--accent); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 0.25rem;
}
.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.25rem 0;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 28px;
  font-size: 12px;
  color: var(--text-2);
  border-radius: 4px;
  cursor: default;
  transition: background 0.12s;
}
.cal-cell--empty { pointer-events: none; }
.cal-cell:not(.cal-cell--empty):hover { background: rgba(189,56,43,0.07); }
.cal-cell--today {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.cal-cell--today:hover { background: var(--accent-dark); }
.cal-cell--has { font-weight: 600; }
.cal-dot {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-cell--today .cal-dot { background: rgba(255,255,255,0.8); }

.cal-footer {
  margin-top: 0.75rem;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 0.625rem;
}

/* Top clients list */
.client-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.client-row:last-child { border-bottom: none; }

.client-rank {
  font-size: 13px;
  font-weight: 700;
  width: 18px;
  flex-shrink: 0;
  text-align: center;
}
.client-info {
  flex: 1;
  min-width: 0;
}
.client-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.client-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.client-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.client-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.client-bar-val {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.client-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Outstanding invoices list */
.out-item {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}
.out-item:last-of-type { border-bottom: none; }

.out-item__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.out-item__client {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.375rem;
}
.out-item__bottom {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}
.out-item__date {
  font-size: 11.5px;
  color: var(--text-muted);
  flex: 1;
}
.out-item__amt {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--dark);
}
.out-view-all {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--accent);
  padding: 0.625rem 0 0;
  font-weight: 500;
  transition: opacity 0.15s;
}
.out-view-all:hover { opacity: 0.75; }

/* ── Login page ─────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-wrap {
  width: 100%;
  max-width: 420px;
  padding: 1.25rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2.25rem 2rem;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.login-logo__name { font-size: 17px; font-weight: 800; color: var(--dark); }
.login-logo__sub  { font-size: 11.5px; color: var(--text-muted); }
.login-heading {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 1.5rem;
}
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--radius);
  padding: 0.6rem 0.875rem;
  font-size: 13px;
  margin-bottom: 1rem;
}
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-submit { width: 100%; justify-content: center; padding: 0.7rem 1rem; font-size: 14px; margin-top: 0.25rem; }
.login-footer-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1.25rem;
}
