/* ============================================================
   Antenall Projektni Sektor — Design System v2 (Light)
   Personality: Clean · Professional · Trustworthy
   Fonts: Plus Jakarta Sans (UI) + Inter (data)
   ============================================================ */

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

/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  /* Backgrounds */
  --bg:               #f1f5f9;
  --bg-elevated:      #ffffff;
  --bg-sidebar:       #111318;
  --bg-card:          #ffffff;
  --bg-card-hover:    #f8fafc;
  --bg-input:         #ffffff;
  --bg-input-focus:   #ffffff;
  --bg-overlay:       rgba(15, 23, 42, 0.45);

  /* Borders */
  --border:           #e2e8f0;
  --border-light:     #cbd5e1;
  --border-focus:     #c8102e;
  --border-table:     #f1f5f9;

  /* Text */
  --text:             #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;
  --text-disabled:    #cbd5e1;
  --text-on-accent:   #ffffff;

  /* Accent — Antenall red */
  --accent:           #c8102e;
  --accent-hover:     #ac0e27;
  --accent-active:    #910e22;
  --accent-muted:     rgba(200, 16, 46, 0.08);
  --accent-muted-hover: rgba(200, 16, 46, 0.13);
  --accent-glow:      rgba(200, 16, 46, 0.22);

  /* Sidebar nav states */
  --sidebar-active-bg:     rgba(200, 16, 46, 0.16);
  --sidebar-active-border: #c8102e;
  --sidebar-hover-bg:      rgba(255, 255, 255, 0.07);

  /* Status */
  --color-success:    #16a34a;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;
  --color-warning:    #d97706;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --color-danger:     #dc2626;
  --color-danger-bg:  #fef2f2;
  --color-danger-border: #fecaca;
  --color-info:       #0284c7;
  --color-info-bg:    #f0f9ff;
  --color-info-border: #bae6fd;
  --color-neutral:    #64748b;
  --color-neutral-bg: #f8fafc;

  /* Quote statuses */
  --status-draft:         #64748b;
  --status-draft-bg:      #f8fafc;
  --status-draft-border:  #e2e8f0;
  --status-waiting:       #d97706;
  --status-waiting-bg:    #fffbeb;
  --status-realized:      #16a34a;
  --status-realized-bg:   #f0fdf4;
  --status-rejected:      #dc2626;
  --status-rejected-bg:   #fef2f2;

  /* Typography */
  --font-ui:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-data:  'Inter', system-ui, sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-md:   0.9375rem;
  --text-lg:   1.0625rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;

  /* 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;

  /* Layout */
  --sidebar-width:     252px;
  --header-height:     62px;
  --content-max:       1400px;

  /* Radius */
  --radius-sm:   6px;
  --radius:      8px;
  --radius-md:   10px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-pill: 9999px;

  /* Shadows — soft, light-theme appropriate */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow:    0 4px 12px rgba(15,23,42,0.08), 0 1px 3px rgba(15,23,42,0.05);
  --shadow-lg: 0 10px 30px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.06);
  --shadow-accent: 0 4px 16px rgba(200, 16, 46, 0.32);

  --transition:    150ms ease;
  --transition-md: 200ms ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-data);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img, svg { display: block; max-width: 100%; }

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font-data);
  font-size: var(--text-base);
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Admin Layout
   ============================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-decoration: none;
}

/* .sidebar-logo-icon and .sidebar-logo-text replaced by img + span in dark sidebar */

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
}

.nav-section {
  margin-bottom: var(--space-1);
}

.nav-section-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-disabled);
  padding: var(--space-4) var(--space-5) var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-4);
  margin: 1px var(--space-3);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: var(--sidebar-hover-bg);
}

.nav-item.active {
  color: var(--accent);
  background: var(--sidebar-active-bg);
  font-weight: 600;
}

.nav-item-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.nav-item.active .nav-item-icon,
.nav-item:hover .nav-item-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  line-height: 1.5;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.sidebar-user:hover { background: var(--sidebar-hover-bg); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Sidebar — dark theme overrides (sve scoped na .sidebar)
   ============================================================ */
.sidebar {
  border-right-color: #1e2128;
}

.sidebar-logo {
  border-bottom-color: #1e2128;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: var(--space-4) var(--space-5);
  height: auto;
  min-height: var(--header-height);
  justify-content: center;
}
.sidebar-logo-img {
  max-width: 118px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
  opacity: 0.88;
}
.sidebar-logo-sub {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4a5568;
}

.sidebar .nav-section-label {
  color: #3d4452;
}

.sidebar .nav-item {
  color: #7c8799;
}
.sidebar .nav-item:hover {
  color: #c8cdd6;
  background: #1a1e26;
}
.sidebar .nav-item.active {
  color: #f0f2f5;
  background: #1e1016;
  border-left: 2px solid #c8102e;
  padding-left: calc(var(--space-4) - 2px);
}
.sidebar .nav-item-icon { color: inherit; opacity: 1; }
.sidebar .nav-item:hover .nav-item-icon,
.sidebar .nav-item.active .nav-item-icon { opacity: 1; }

.sidebar .nav-badge {
  background: #c8102e;
}

.sidebar-footer {
  border-top-color: #1e2128;
}
.sidebar .user-name {
  color: #c4c9d4;
}
.sidebar .user-role {
  color: #4a5568;
}
.sidebar-user:hover {
  background: #1a1e26;
}

/* ============================================================
   Main wrapper & Header
   ============================================================ */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  height: var(--header-height);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-search {
  flex: 1;
  max-width: 380px;
  position: relative;
}
.header-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 14px;
  height: 14px;
}
.header-search input {
  width: 100%;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-4) 0 34px;
  color: var(--text);
  font-size: var(--text-sm);
  transition: all var(--transition);
  outline: none;
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search input:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* Global search dropdown */
#gs-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 200;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
.gs-group-label {
  padding: 8px 14px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.gs-group-label:first-child { border-top: none; }
.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition);
}
.gs-item:hover,
.gs-item.active { background: var(--bg-hover); }
.gs-item-body { flex: 1; min-width: 0; }
.gs-item-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-item-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.gs-badge-draft    { background: rgba(100,116,139,0.15); color: var(--text-secondary); }
.gs-badge-sent     { background: rgba(56,189,248,0.15);  color: #38bdf8; border-color: rgba(56,189,248,0.3); }
.gs-badge-accepted { background: rgba(34,197,94,0.15);   color: #22c55e; border-color: rgba(34,197,94,0.3); }
.gs-badge-rejected { background: rgba(239,68,68,0.15);   color: #ef4444; border-color: rgba(239,68,68,0.3); }
.gs-empty {
  padding: 16px 14px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
  transition: all var(--transition);
  background: transparent;
  border: 1px solid transparent;
}
.header-btn:hover {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
}
.header-btn svg { width: 17px; height: 17px; }

.header-btn-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: var(--color-danger);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-elevated);
}

/* User dropdown menu */
#user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  z-index: 200;
  overflow: hidden;
}
#user-menu-dropdown.open { display: block; }
.user-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.user-menu-name {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.user-menu-item:hover { background: var(--bg-hover); color: var(--text); }
.user-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.user-menu-item.danger { color: var(--color-danger); border-top: 1px solid var(--border); }
.user-menu-item.danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }

/* ============================================================
   Content
   ============================================================ */
.content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max);
  width: 100%;
}

.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 3px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-disabled); }
.breadcrumb-current { color: var(--text-secondary); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
}
.card-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-md), transform var(--transition-md);
}
.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.stat-card-value {
  font-family: var(--font-ui);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1;
}
.stat-card-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}
.stat-card-icon {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card-icon svg { width: 19px; height: 19px; }

.stat-card-icon.accent  { background: var(--accent-muted);      color: var(--accent); }
.stat-card-icon.success { background: var(--color-success-bg);  color: var(--color-success); }
.stat-card-icon.warning { background: var(--color-warning-bg);  color: var(--color-warning); }
.stat-card-icon.danger  { background: var(--color-danger-bg);   color: var(--color-danger); }

/* ============================================================
   Grids
   ============================================================ */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--space-4); }
.grid-sidebar {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
  align-items: start;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(200,16,46,0.22);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-accent);
  color: #fff;
}
.btn-primary:active { background: var(--accent-active); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--border-light);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

.btn-sm { padding: 5px 11px; font-size: var(--text-xs); gap: 5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 10px 22px; font-size: var(--text-md); border-radius: var(--radius-md); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   Tables
   ============================================================ */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.table-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* Reusable inline search bar (used in table headers) */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-4) 0 32px;
  color: var(--text);
  font-size: var(--text-sm);
  outline: none;
  transition: all var(--transition);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-toolbar-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-right: auto;
}
.table-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead th {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  padding: 10px var(--space-4);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
thead th:first-child { padding-left: var(--space-5); }
thead th:last-child  { padding-right: var(--space-5); }

thead th.sortable { cursor: pointer; transition: color var(--transition); }
thead th.sortable:hover { color: var(--text); }
thead th.sort-asc::after  { content: ' ↑'; color: var(--accent); }
thead th.sort-desc::after { content: ' ↓'; color: var(--accent); }

tbody tr {
  border-bottom: 1px solid var(--border-table);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody td {
  padding: 12px var(--space-4);
  color: var(--text);
  vertical-align: middle;
}
tbody td:first-child { padding-left: var(--space-5); }
tbody td:last-child  { padding-right: var(--space-5); }

.td-muted { color: var(--text-secondary); }
.td-mono  { font-family: 'SFMono-Regular', 'Consolas', monospace; font-size: var(--text-xs); }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: var(--space-5); }

.form-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-control {
  width: 100%;
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-3);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-data);
  transition: all var(--transition);
  outline: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow-xs);
}
.form-control::placeholder { color: var(--text-disabled); }
.form-control:hover { border-color: var(--border-light); }
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.form-control:disabled { opacity: 0.55; cursor: not-allowed; background: var(--bg); }
.form-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.10);
}

textarea.form-control {
  height: auto;
  padding: var(--space-3);
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-hint  { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }
.form-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: var(--space-2); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

/* ============================================================
   Badges / Status
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-draft    { background: var(--status-draft-bg);    color: var(--status-draft);    border-color: var(--status-draft-border); }
.badge-waiting  { background: var(--status-waiting-bg);  color: var(--status-waiting); }
.badge-realized { background: var(--status-realized-bg); color: var(--status-realized); }
.badge-rejected { background: var(--status-rejected-bg); color: var(--status-rejected); }
.badge-success  { background: var(--color-success-bg);   color: var(--color-success);  border-color: var(--color-success-border); }
.badge-warning  { background: var(--color-warning-bg);   color: var(--color-warning);  border-color: var(--color-warning-border); }
.badge-danger   { background: var(--color-danger-bg);    color: var(--color-danger);   border-color: var(--color-danger-border); }
.badge-info     { background: var(--color-info-bg);      color: var(--color-info);     border-color: var(--color-info-border); }
.badge-neutral  { background: var(--color-neutral-bg);   color: var(--color-neutral); }
.badge-accent   { background: var(--accent-muted);       color: var(--accent); }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}
.page-btn:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert a { font-weight: 600; color: inherit; text-decoration: underline; }

.alert-error   { background: var(--color-danger-bg);  border-color: var(--color-danger-border);  color: var(--color-danger); }
.alert-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }
.alert-warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning); }
.alert-info    { background: var(--color-info-bg);    border-color: var(--color-info-border);    color: var(--color-info); }

/* ============================================================
   Modals
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-md);
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: transform var(--transition-md);
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
  background: transparent;
  border: none;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body   { padding: var(--space-6); }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============================================================
   Toast notifications
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  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);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  min-width: 260px;
  max-width: 380px;
  pointer-events: all;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  animation: toast-in 200ms ease;
}
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-danger); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-icon svg { width: 16px; height: 16px; margin-top: 1px; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error   .toast-icon { color: var(--color-danger); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info    .toast-icon { color: var(--accent); }
.toast-msg { flex: 1; color: var(--text); line-height: 1.4; }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
}
.empty-state-icon {
  width: 44px;
  height: 44px;
  color: var(--text-disabled);
  margin-bottom: var(--space-4);
}
.empty-state-title {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.empty-state-text { font-size: var(--text-sm); color: var(--text-muted); }

/* ============================================================
   Skeleton
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Auth layout
   ============================================================ */
.auth-layout {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  text-decoration: none;
}
.auth-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(200,16,46,0.35);
}
.auth-logo-text {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.auth-title {
  font-family: var(--font-ui);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-1);
}
.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-6);
}

.auth-footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ============================================================
   Dashboard specifics
   ============================================================ */
.dashboard-welcome {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}
.dashboard-welcome span { color: var(--accent); }

.quote-number-link {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.quote-number-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================================
   Utility classes
   ============================================================ */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.mt-4   { margin-top: var(--space-4); }
.mt-6   { margin-top: var(--space-6); }
.mb-4   { margin-bottom: var(--space-4); }
.mb-6   { margin-bottom: var(--space-6); }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: var(--text-sm); }
.text-xs    { font-size: var(--text-xs); }
.truncate   { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.divider    { height: 1px; background: var(--border); margin: var(--space-4) 0; }

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--color-warning);
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* ============================================================
   Spinner
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(200,16,46,0.20);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Focus
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: var(--space-4); }
}
