:root {
  --bg-dark: #090d16;
  --bg-card: #111827;
  --bg-card-alt: #162032;
  --border-color: #233149;
  --border-focus: #f59e0b;
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary-gold: #f59e0b;
  --primary-gold-hover: #d97706;
  --primary-gold-glow: rgba(245, 158, 11, 0.25);
  --success: #10b981;
  --danger: #ef4444;
  --info: #3b82f6;
  --purple: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* HEADER */
.app-header {
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-wrapper {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  box-shadow: 0 4px 14px var(--primary-gold-glow);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #fef3c7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #34d399;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-alt);
  padding: 5px 14px 5px 6px;
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: #2563eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 700;
}

.user-role {
  font-size: 0.68rem;
  color: var(--primary-gold);
  font-weight: 600;
}

/* NAV TABS */
.nav-tabs {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  color: var(--primary-gold);
  border-bottom-color: var(--primary-gold);
}

.nav-tab svg {
  width: 18px;
  height: 18px;
}

/* MAIN */
.app-main {
  max-width: 1280px;
  width: 100%;
  margin: 28px auto;
  padding: 0 24px 40px;
  flex: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* GRID LAYOUT FOR TAB 1 */
.grid-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

@media (max-width: 992px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.card-header {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.card-header.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.card-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-bubble {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-bubble.gold {
  background: rgba(245, 158, 11, 0.15);
  color: var(--primary-gold);
}

/* FORM CONTROLS */
.form-group {
  margin-bottom: 18px;
  position: relative;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}

label svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 12px 14px;
  font-size: 0.92rem;
  transition: all 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary-gold);
  box-shadow: 0 0 0 3px var(--primary-gold-glow);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix-wrapper .prefix {
  position: absolute;
  left: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.input-prefix-wrapper .gold-prefix {
  color: var(--primary-gold);
}

.form-control.with-prefix {
  padding-left: 32px;
}

.form-control.gold-input {
  border-color: rgba(245, 158, 11, 0.4);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fef08a;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  box-shadow: 0 4px 14px var(--primary-gold-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-alt);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #1e293b;
}

.btn-whatsapp {
  background: #25d366;
  color: #000;
}

.btn-whatsapp:hover {
  background: #1eb956;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1rem;
  width: 100%;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--primary-gold);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn-icon-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* SEARCH DROPDOWN */
.search-select-wrapper {
  position: relative;
}

.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  z-index: 50;
  display: none;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dropdown-item:hover {
  background: #334155;
}

.dropdown-item strong {
  font-size: 0.88rem;
  color: #fff;
}

.dropdown-item span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.selected-client-preview {
  margin-top: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-gold);
  color: #000;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.preview-info strong {
  font-size: 0.9rem;
  color: #fff;
}

.preview-info span {
  font-size: 0.78rem;
  color: #cbd5e1;
}

/* TICKET CARD */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ticket-card {
  background: linear-gradient(180deg, #162032 0%, #0f172a 100%);
  border: 1px solid #334155;
}

.ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ticket-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(245, 158, 11, 0.2);
  color: var(--primary-gold);
  padding: 4px 8px;
  border-radius: 4px;
}

.ticket-logo {
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.ticket-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
}

.t-label {
  color: var(--text-muted);
}

.t-value {
  font-weight: 600;
  color: #fff;
}

.ticket-divider {
  border: none;
  border-top: 1px dashed #334155;
  margin: 12px 0;
}

.ticket-calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.ticket-calc-row strong {
  font-size: 1rem;
}

.gold-text {
  color: var(--primary-gold);
}

.alert-text {
  color: #f87171;
}

.ticket-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
  font-size: 0.72rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ticket-footer svg {
  width: 14px;
  height: 14px;
  color: #10b981;
}

/* STATS CARD */
.stats-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.quick-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-kpi {
  background: var(--bg-card-alt);
  padding: 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.qk-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.qk-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-gold);
  margin-top: 4px;
}

/* KPI GRID 4 */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .kpi-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.green-kpi .kpi-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.blue-kpi .kpi-icon { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.orange-kpi .kpi-icon { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.purple-kpi .kpi-icon { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

.kpi-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-data h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin-top: 2px;
}

/* DATA TABLES */
.table-toolbar {
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  max-width: 400px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-box .form-control {
  padding-left: 38px;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  padding: 12px 14px;
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: #cbd5e1;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge.warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge.danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge.info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  animation: modalScale 0.25s ease-out;
}

.modal-card.modal-lg {
  max-width: 720px;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* SUCCESS MODAL & PRINTABLE INVOICE */
.success-icon-bubble {
  width: 44px;
  height: 44px;
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.invoice-printable {
  background: #ffffff;
  color: #1e293b;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  margin-bottom: 24px;
  font-size: 0.88rem;
}

.brand-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.inv-logo-wrap {
  display: flex;
  align-items: center;
}

.inv-logo-img {
  height: 54px;
  width: auto;
  object-fit: contain;
  display: block;
}

.inv-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inv-brand-info {
  display: flex;
  flex-direction: column;
}

.inv-brand-name {
  font-size: 1.22rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.02em;
  margin-bottom: 1px;
}

.inv-tagline, .inv-contact {
  font-size: 0.73rem;
  color: #64748b;
  line-height: 1.35;
}

.inv-notes-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 14px;
}

.inv-notes-box .inv-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #b45309;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 2px;
}

.inv-notes-box p {
  font-size: 0.84rem;
  color: #1e293b;
  margin: 0;
  line-height: 1.4;
}

.inv-meta {
  text-align: right;
}

.inv-num {
  font-size: 1.2rem;
  font-weight: 800;
  color: #f59e0b;
}

.inv-date {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
}

.inv-status-badge {
  display: inline-block;
  background: #dcfce7;
  color: #15803d;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 4px;
}

.inv-sep {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 16px 0;
}

.inv-client-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 20px;
}

.inv-client-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inv-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.inv-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  padding: 8px 10px;
  border-bottom: 2px solid #e2e8f0;
}

.inv-table td {
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
}

.inv-totals-box {
  background: #f8fafc;
  border-radius: 6px;
  padding: 14px;
  max-width: 320px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}

.inv-totals-row.green {
  color: #15803d;
  font-size: 1rem;
}

.inv-totals-row.alert {
  color: #b91c1c;
}

.inv-footer {
  margin-top: 24px;
  text-align: center;
  color: #64748b;
  font-size: 0.8rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
}

.inv-footer .small-text {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
}

.success-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .success-actions {
    grid-template-columns: 1fr;
  }
}

.mt-4 { margin-top: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
