/* ============================================================
   BillTrack Pro — Main CSS
   Property bills tracking design system
   Primary: Plum #A21CAF
   ============================================================ */

:root {
  /* Brand Colors (SPEC §Identity) */
  --color-primary:        #A21CAF;
  --color-primary-dark:   #701A75;
  --color-primary-light:  #FAE8FF;
  --color-primary-mid:    #C026D3;
  --color-success:        #059669;
  --color-success-light:  #D1FAE5;
  --color-warning:        #D97706;
  --color-warning-light:  #FEF3C7;
  --color-danger:         #DC2626;
  --color-danger-light:   #FEE2E2;
  --color-info:           #0891B2;
  --color-info-light:     #CFFAFE;
  --color-purple:         #7C3AED;
  --color-purple-light:   #EDE9FE;

  /* Neutrals */
  --bg:               #F1F5F9;
  --bg-secondary:     #F8FAFC;
  --card-bg:          #FFFFFF;
  --text-primary:     #1E293B;
  --text-secondary:   #64748B;
  --text-muted:       #94A3B8;
  --border:           #E2E8F0;
  --border-focus:     #A21CAF;

  /* Typography */
  --font-family:    'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-size-base: 16px;
  --font-size-sm:   14px;
  --font-size-xs:   12px;
  --font-size-lg:   18px;
  --font-size-xl:   20px;
  --line-height-base: 1.5;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -4px rgba(0,0,0,.06);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,.10), 0 8px 10px -6px rgba(0,0,0,.06);
  --shadow-top: 0 -2px 10px rgba(0,0,0,.08);

  --header-height:     60px;
  --bottom-nav-height: 64px;
  --sidebar-width: 240px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  --z-header: 100;
  --z-bottom: 100;
  --z-modal:  1000;
  --z-toast:  9999;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:             #0F172A;
    --bg-secondary:   #1E293B;
    --card-bg:        #1E293B;
    --text-primary:   #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted:     #64748B;
    --border:         #334155;
    --color-primary-light: #4A044E;
    --color-success-light: #064E3B;
    --color-warning-light: #78350F;
    --color-danger-light:  #7F1D1D;
    --color-info-light:    #164E63;
    --color-purple-light:  #2E1065;
  }
}
[data-theme="dark"] {
  --bg:             #0F172A;
  --bg-secondary:   #1E293B;
  --card-bg:        #1E293B;
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;
  --border:         #334155;
  --color-primary-light: #4A044E;
  --color-success-light: #064E3B;
  --color-warning-light: #78350F;
  --color-danger-light:  #7F1D1D;
  --color-info-light:    #164E63;
  --color-purple-light:  #2E1065;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--font-size-base); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; line-height: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
table { border-collapse: collapse; border-spacing: 0; }

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1.05rem; font-weight: 600; }
p  { color: var(--text-secondary); margin-bottom: var(--space-3); }
p:last-child { margin-bottom: 0; }
.text-xs   { font-size: var(--font-size-xs)   !important; }
.text-sm   { font-size: var(--font-size-sm)   !important; }
.text-lg   { font-size: var(--font-size-lg)   !important; }
.text-muted    { color: var(--text-muted)    !important; }
.text-primary  { color: var(--color-primary) !important; }
.text-success  { color: var(--color-success) !important; }
.text-danger   { color: var(--color-danger)  !important; }
.text-warning  { color: var(--color-warning) !important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ============================================================
   APP SHELL — desktop sidebar+topbar, mobile bottom-nav
   ============================================================ */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.app-sidebar {
  display: none;
}
@media (min-width: 960px) {
  .app-sidebar {
    display: flex; position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width); flex-direction: column;
    background: var(--card-bg); border-right: 1px solid var(--border);
    z-index: 200; overflow-y: auto; overflow-x: hidden;
  }
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); text-decoration: none; flex-shrink: 0; }
.sidebar-logo { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.sidebar-app-name { font-size: 13px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.sidebar-app-name strong { color: var(--color-primary); font-weight: 800; }
.sidebar-nav { flex: 1; padding: var(--space-3) 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: var(--space-3) var(--space-5) var(--space-1); margin-top: var(--space-2); }
.sidebar-nav__item { display: flex; align-items: center; gap: var(--space-3); padding: 9px var(--space-5); margin: 0 var(--space-2); border-radius: var(--radius-md); text-decoration: none; font-size: 13px; font-weight: 500; color: var(--text-secondary); transition: background .12s, color .12s; }
.sidebar-nav__item svg { flex-shrink: 0; opacity: .65; transition: opacity .12s; }
.sidebar-nav__item:hover { background: var(--color-primary-light); color: var(--color-primary); text-decoration: none; }
.sidebar-nav__item:hover svg { opacity: 1; }
.sidebar-nav__item.is-active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 700; }
.sidebar-nav__item.is-active svg { opacity: 1; }
.sidebar-divider { height: 1px; background: var(--border); margin: var(--space-2) var(--space-4); }
.sidebar-user { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.sidebar-user__avatar { width: 32px; height: 32px; border-radius: var(--radius-full); background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.sidebar-user__info { flex: 1; min-width: 0; }
.sidebar-user__name { font-size: 12px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user__role { font-size: 10px; color: var(--text-muted); }
.sidebar-user__logout { color: var(--text-muted); flex-shrink: 0; }
.sidebar-user__logout:hover { color: var(--color-danger); }

/* Mobile top header */
.app-header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-height); background: var(--color-primary); box-shadow: var(--shadow-md); z-index: var(--z-header); }
@media (min-width: 960px) { .app-header { display: none; } }
.app-header__inner { display: flex; align-items: center; justify-content: space-between; height: 100%; padding: 0 var(--space-4); gap: var(--space-2); }
.app-header__brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; }
.app-header__logo { width: 30px; height: 30px; border-radius: var(--radius-sm); background: rgba(255,255,255,.20); color: #fff; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-header__app-name { color: #fff; font-size: 14px; font-weight: 700; line-height: 1; }
.app-header__actions { display: flex; align-items: center; gap: 2px; }
.app-header__icon-btn { width: 36px; height: 36px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.9); transition: background var(--transition-fast); position: relative; }
.app-header__icon-btn:hover { background: rgba(255,255,255,.15); }
.app-header__avatar-btn { width: 32px; height: 32px; border-radius: var(--radius-full); background: rgba(255,255,255,.20); display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; font-size: 12px; font-weight: 700; }

/* Desktop topbar */
.app-topbar { display: none; }
@media (min-width: 960px) {
  .app-topbar { display: flex; position: fixed; top: 0; left: var(--sidebar-width); right: 0; height: var(--header-height); background: var(--card-bg); border-bottom: 1px solid var(--border); align-items: center; padding: 0 var(--space-8); gap: var(--space-4); z-index: 150; }
}
.app-topbar__title { flex: 1; font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.app-topbar__actions { display: flex; align-items: center; gap: var(--space-2); }
.app-topbar__icon-btn { width: 38px; height: 38px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; background: transparent; border: none; cursor: pointer; color: var(--text-primary); position: relative; transition: background .12s; }
.app-topbar__icon-btn:hover { background: var(--color-primary-light); color: var(--color-primary); }
.app-topbar__avatar-btn { width: 36px; height: 36px; border-radius: var(--radius-full); background: var(--color-primary); color: #fff; border: none; cursor: pointer; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.app-topbar__divider { width: 1px; height: 24px; background: var(--border); margin: 0 var(--space-1); }

.theme-toggle__moon { display: block; }
.theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun  { display: block; }

.badge--notif { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: var(--radius-full); background: var(--color-danger); color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 1.5px solid var(--color-primary); }
.app-topbar .badge--notif { border-color: var(--card-bg); }

/* Page content */
.page-content { flex: 1; padding-top: var(--header-height); padding-bottom: calc(var(--bottom-nav-height) + var(--space-4)); }
@media (min-width: 960px) {
  .page-content { margin-left: var(--sidebar-width); padding-top: calc(var(--header-height) + var(--space-6)); padding-bottom: var(--space-10); padding-left: var(--space-8); padding-right: var(--space-8); }
}
.page-inner { padding: var(--space-4); max-width: 1200px; margin: 0 auto; }
@media (min-width: 960px) { .page-inner { padding: 0; } }

/* Bottom nav (mobile only) */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-height); background: var(--card-bg); border-top: 1px solid var(--border); box-shadow: var(--shadow-top); z-index: var(--z-bottom); display: grid; align-items: center; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 960px) { .bottom-nav { display: none; } }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: var(--space-2) 0; text-decoration: none; color: var(--text-muted); position: relative; }
.nav-item:hover { text-decoration: none; }
.nav-item.active { color: var(--color-primary); }
.nav-item__label { font-size: 10px; font-weight: 600; }

/* ============================================================
   PAGE HEADER / TOOLBAR
   ============================================================ */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-header-sub { color: var(--text-muted); font-size: var(--font-size-sm); margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.toolbar .spacer { flex: 1; }

/* ============================================================
   STAT CARDS / KPI
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin-bottom: var(--space-5); }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card-bg); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: var(--space-4); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: var(--space-1); }
.stat-card svg { color: var(--color-primary); }
.stat-card.success svg { color: var(--color-success); }
.stat-card.warning svg { color: var(--color-warning); }
.stat-card.danger  svg { color: var(--color-danger); }
.stat-card.info    svg { color: var(--color-info); }
.stat-value { font-size: 1.35rem; font-weight: 800; color: var(--text-primary); line-height: 1; margin-top: var(--space-1); }
.stat-label { font-size: var(--font-size-xs); color: var(--text-secondary); font-weight: 600; }
.stat-sub   { font-size: 10px; color: var(--text-muted); margin: 0; }

/* ============================================================
   CARDS / LIST ITEMS
   ============================================================ */
.card { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: var(--space-4); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.card-header h3 { font-size: 1rem; margin: 0; }
.card-body { padding: var(--space-4); }

.list-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--border); text-decoration: none; transition: background var(--transition-fast); color: inherit; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-secondary); text-decoration: none; }
.list-item__icon { width: 42px; height: 42px; border-radius: var(--radius-md); background: var(--color-primary-light); color: var(--color-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; font-weight: 700; }
.list-item__icon img { width: 100%; height: 100%; object-fit: cover; }
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; color: var(--text-primary); font-size: var(--font-size-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item__meta  { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }
.list-item__right { text-align: right; flex-shrink: 0; }
.list-item__amount { font-weight: 700; font-size: var(--font-size-sm); color: var(--text-primary); }

/* ============================================================
   GRID CARDS (collections grid view)
   ============================================================ */
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-4); }
.entry-card { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; text-decoration: none; display: block; color: inherit; transition: box-shadow var(--transition-fast); }
.entry-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.entry-card__photo { width: 100%; height: 140px; object-fit: cover; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 2rem; }
.entry-card__body { padding: var(--space-3) var(--space-4); }
.entry-card__amount { font-weight: 800; color: var(--text-primary); font-size: 1.05rem; margin-bottom: 2px; }
.entry-card__client { font-size: var(--font-size-xs); color: var(--text-secondary); margin-bottom: var(--space-2); }
.entry-card__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* ============================================================
   BADGES / CHIPS
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--font-size-xs); font-weight: 600; line-height: 1.6; }
.badge--primary   { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge--success   { background: var(--color-success-light); color: var(--color-success); }
.badge--warning   { background: var(--color-warning-light); color: var(--color-warning); }
.badge--danger    { background: var(--color-danger-light);  color: var(--color-danger); }
.badge--info      { background: var(--color-info-light);    color: var(--color-info); }
.badge--secondary { background: var(--bg);                  color: var(--text-secondary); }
.badge--purple    { background: var(--color-purple-light);  color: var(--color-purple); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 14px; border-radius: var(--radius-full); border: 1.5px solid var(--border); background: var(--card-bg); font-size: var(--font-size-xs); font-weight: 600; color: var(--text-secondary); white-space: nowrap; cursor: pointer; transition: all var(--transition-fast); }
.chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.chip:hover:not(.active) { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.filter-chips { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filter-chips::-webkit-scrollbar { display: none; }

.tag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 10px var(--space-5); border-radius: var(--radius-md); font-size: var(--font-size-sm); font-weight: 600; line-height: 1; cursor: pointer; transition: all var(--transition-fast); border: 1.5px solid transparent; text-decoration: none; }
.btn--primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn--primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); text-decoration: none; }
.btn--secondary { background: var(--card-bg); color: var(--text-secondary); border-color: var(--border); }
.btn--secondary:hover { background: var(--bg); text-decoration: none; }
.btn--success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn--success:hover { opacity: .9; text-decoration: none; }
.btn--danger  { background: var(--color-danger);  color: #fff; border-color: var(--color-danger); }
.btn--danger:hover { opacity: .9; text-decoration: none; }
.btn--outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn--outline:hover { background: var(--color-primary-light); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn--ghost:hover { background: var(--bg); text-decoration: none; }
.btn--sm { padding: 7px var(--space-4); font-size: var(--font-size-xs); }
.btn--lg { padding: 13px var(--space-6); font-size: var(--font-size-base); }
.btn--full { width: 100%; }
.btn--icon { padding: 8px; width: 36px; height: 36px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--space-5); }
.form-label { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-2); }
.form-label .required { color: var(--color-danger); margin-left: 2px; }
.form-control { width: 100%; padding: 10px var(--space-4); border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--card-bg); color: var(--text-primary); font-size: var(--font-size-sm); transition: border-color var(--transition-fast), box-shadow var(--transition-fast); appearance: none; }
.form-control:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(162,28,175,.15); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: var(--space-1); }
.form-error { font-size: var(--font-size-xs); color: var(--color-danger); margin-top: var(--space-1); }
.form-control.is-invalid { border-color: var(--color-danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.form-check { display: flex; align-items: center; gap: var(--space-2); }
.form-check input { width: 16px; height: 16px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.data-table { width: 100%; min-width: 640px; }
.data-table th { padding: var(--space-3) var(--space-4); text-align: left; font-size: var(--font-size-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--bg-secondary); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 4px; }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); font-size: var(--font-size-sm); color: var(--text-secondary); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-secondary); }
.data-table td strong { color: var(--text-primary); font-weight: 600; }
.table-thumb { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--bg); background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }

/* ============================================================
   KANBAN
   ============================================================ */
.kanban-board { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: var(--space-4); overflow-x: auto; align-items: start; }
@media (max-width: 900px) { .kanban-board { grid-template-columns: 1fr; } }
.kanban-col { background: var(--bg-secondary); border-radius: var(--radius-lg); border: 1px solid var(--border); min-height: 120px; }
.kanban-col__header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); font-weight: 700; font-size: var(--font-size-sm); }
.kanban-col__count { background: var(--card-bg); border-radius: var(--radius-full); padding: 1px 9px; font-size: 11px; color: var(--text-muted); }
.kanban-col__body { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); max-height: 70vh; overflow-y: auto; }
.kanban-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); box-shadow: var(--shadow-xs); }
.kanban-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-1); }
.kanban-card__amount { font-weight: 800; color: var(--text-primary); }
.kanban-card__client { font-size: var(--font-size-xs); color: var(--text-secondary); margin-bottom: var(--space-2); }
.kanban-card__tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--space-2); }
.kanban-card__meta { font-size: 11px; color: var(--text-muted); margin-bottom: var(--space-2); }
.kanban-card__actions { display: flex; gap: var(--space-2); }
.kanban-card__actions select { flex: 1; }

/* ============================================================
   CALENDAR
   ============================================================ */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.cal-dow { background: var(--bg-secondary); padding: var(--space-2); text-align: center; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.cal-day { background: var(--card-bg); min-height: 90px; padding: var(--space-2); position: relative; }
.cal-day.is-outside { background: var(--bg); opacity: .5; }
.cal-day.is-today .cal-day__num { background: var(--color-primary); color: #fff; }
.cal-day__num { font-size: 11px; font-weight: 700; color: var(--text-secondary); width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 50%; margin-bottom: 4px; }
.cal-day__entries { display: flex; flex-direction: column; gap: 2px; }
.cal-entry { font-size: 10px; padding: 2px 5px; border-radius: 4px; background: var(--color-primary-light); color: var(--color-primary-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; display: block; }
.cal-entry.status-verified { background: var(--color-success-light); color: var(--color-success); }
.cal-entry.status-flagged { background: var(--color-danger-light); color: var(--color-danger); }
.cal-entry:hover { text-decoration: none; opacity: .8; }
.cal-day__more { font-size: 9px; color: var(--text-muted); }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar { display: flex; align-items: center; gap: var(--space-3); background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--radius-full); padding: 8px var(--space-4); }
.search-bar:focus-within { border-color: var(--border-focus); }
.search-bar input { flex: 1; border: none; background: none; color: var(--text-primary); font-size: var(--font-size-sm); outline: none; }
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

/* ============================================================
   VIEW SWITCHER
   ============================================================ */
.view-toggle-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.view-btn { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted); padding: 6px 12px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; font-weight: 600; text-decoration: none; transition: background .15s, color .15s, border-color .15s; }
.view-btn:hover { color: var(--text-primary); border-color: var(--color-primary); text-decoration: none; }
.view-btn.active-view { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ============================================================
   MODAL
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity var(--transition-base); padding: var(--space-4); }
.modal.is-open { opacity: 1; pointer-events: all; }
.modal__overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.modal__content { position: relative; background: var(--card-bg); border-radius: var(--radius-xl); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: var(--space-5); transform: translateY(20px); transition: transform var(--transition-base); }
.modal.is-open .modal__content { transform: translateY(0); }
.modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-5); }
.modal__title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.modal__close { width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: background var(--transition-fast); }
.modal__close:hover { background: var(--bg); }

#confirm-modal { position: fixed; inset: 0; z-index: calc(var(--z-modal) + 10); display: flex; align-items: center; justify-content: center; padding: var(--space-5); background: rgba(0,0,0,.5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity var(--transition-base); }
#confirm-modal.is-open { opacity: 1; pointer-events: all; }
.confirm-dialog { background: var(--card-bg); border-radius: var(--radius-xl); padding: var(--space-6); max-width: 320px; width: 100%; text-align: center; box-shadow: var(--shadow-xl); transform: scale(.95); transition: transform var(--transition-base); }
#confirm-modal.is-open .confirm-dialog { transform: scale(1); }
.confirm-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: var(--space-2); }
.confirm-message { font-size: var(--font-size-sm); color: var(--text-secondary); margin-bottom: var(--space-5); }
.confirm-actions { display: flex; gap: var(--space-3); }
.confirm-actions .btn { flex: 1; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container { position: fixed; top: calc(var(--header-height) + var(--space-3)); left: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); width: min(calc(100% - 32px), 420px); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--card-bg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); opacity: 0; transform: translateY(-12px) scale(.96); transition: all var(--transition-base); pointer-events: all; }
.toast--show { opacity: 1; transform: translateY(0) scale(1); }
.toast--success { border-left: 4px solid var(--color-success); }
.toast--error   { border-left: 4px solid var(--color-danger); }
.toast--warning { border-left: 4px solid var(--color-warning); }
.toast--info    { border-left: 4px solid var(--color-info); }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast__message { flex: 1; font-size: var(--font-size-sm); color: var(--text-primary); font-weight: 500; }
.toast__close { flex-shrink: 0; color: var(--text-muted); margin-top: 1px; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-5); background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); }
.auth-card { background: var(--card-bg); border-radius: var(--radius-xl); padding: var(--space-8); width: 100%; max-width: 420px; box-shadow: var(--shadow-xl); }
.auth-logo { width: 56px; height: 56px; border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; margin: 0 auto var(--space-5); }
.auth-title { text-align: center; font-size: 1.3rem; font-weight: 800; color: var(--text-primary); margin-bottom: var(--space-1); }
.auth-subtitle { text-align: center; font-size: var(--font-size-sm); color: var(--text-muted); margin-bottom: var(--space-6); }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-5); background: var(--bg-secondary); border-radius: var(--radius-lg); margin-bottom: var(--space-5); }
#qr-canvas-wrap { width: 220px; height: 220px; background: #fff; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); padding: var(--space-2); }
#qr-canvas-wrap img, #qr-canvas-wrap canvas { width: 100% !important; height: 100% !important; }
.qr-status { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); }
.qr-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.qr-status.state-pending .dot { background: var(--color-warning); animation: pulse-dot 1.4s infinite; }
.qr-status.state-scanned .dot { background: var(--color-info); }
.qr-status.state-approved .dot { background: var(--color-success); }
.qr-status.state-error .dot, .qr-status.state-expired .dot, .qr-status.state-denied .dot { background: var(--color-danger); }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.auth-collapse { border-top: 1px solid var(--border); margin-top: var(--space-4); padding-top: var(--space-4); }
.auth-collapse__toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); padding: var(--space-2) 0; }
.auth-collapse__toggle:hover { color: var(--color-primary); }
.auth-collapse__body { display: none; padding-top: var(--space-3); }
.auth-collapse.is-open .auth-collapse__body { display: block; }
.auth-collapse__toggle svg { transition: transform .2s; }
.auth-collapse.is-open .auth-collapse__toggle svg { transform: rotate(180deg); }

.auth-lockout { background: var(--color-danger-light); color: var(--color-danger); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--font-size-sm); margin-bottom: var(--space-4); }
.auth-info-banner { background: var(--color-success-light); color: var(--color-success); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--font-size-sm); margin-bottom: var(--space-4); }
/* "Verified, but an admin still has to approve you" (SPEC "Self-signup
   approval gate") — deliberately amber, i.e. neither the green of a
   completed action nor the red of a failure, because the user did
   everything right and simply has to wait. */
.auth-pending-banner { background: var(--color-warning-light); color: var(--color-warning); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--font-size-sm); margin-bottom: var(--space-4); }

/* ============================================================
   PHOTO / EXIF / MAP
   ============================================================ */
.photo-upload-zone { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: var(--space-8) var(--space-6); text-align: center; cursor: pointer; transition: all var(--transition-fast); background: var(--bg-secondary); }
.photo-upload-zone.dragover { border-color: var(--color-primary); background: var(--color-primary-light); }
.photo-upload-zone p { color: var(--text-muted); font-size: var(--font-size-sm); margin: 0; }
.photo-upload-zone span { color: var(--color-primary); font-weight: 600; }
.photo-preview { max-width: 220px; border-radius: var(--radius-md); margin-top: var(--space-3); }

.detail-photo { width: 100%; max-width: 420px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.exif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); font-size: var(--font-size-sm); }
.exif-grid dt { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.exif-grid dd { color: var(--text-primary); font-weight: 600; margin-bottom: var(--space-2); }

#map-canvas { width: 100%; height: 560px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }

/* ============================================================
   FAB (mobile create button)
   ============================================================ */
.fab { position: fixed; bottom: calc(var(--bottom-nav-height) + var(--space-4)); right: var(--space-4); width: 56px; height: 56px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(162,28,175,.4); z-index: 90; }
@media (min-width: 960px) { .fab { display: none; } }

/* ============================================================
   PROGRESS / LOADING
   ============================================================ */
#loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); z-index: 9998; opacity: 0; pointer-events: none; transition: opacity var(--transition-base); }
[data-theme="dark"] #loading-overlay { background: rgba(15,23,42,.8); }
#loading-overlay.is-visible { opacity: 1; pointer-events: all; }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-text { font-size: var(--font-size-sm); color: var(--text-secondary); font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   UTILITIES
   ============================================================ */
.d-flex  { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.flex-wrap { flex-wrap: wrap; }
.empty-state { text-align: center; padding: var(--space-12) var(--space-6); color: var(--text-muted); }
.empty-state svg { margin: 0 auto var(--space-4); opacity: .5; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state p  { font-size: var(--font-size-sm); margin-bottom: var(--space-5); }

.pagination { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; margin-top: var(--space-4); }
.page-link { display: flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 8px; border-radius: var(--radius-md); border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-secondary); font-size: var(--font-size-sm); font-weight: 500; transition: all var(--transition-fast); text-decoration: none; }
.page-link:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.page-link.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.role-tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
