/* CARDIOFACTU GENERAL STYLES & VARIABLES */

:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: #1e293b;
  --sidebar-active-text: #2dd4bf;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #f0fdfa;
  --accent: #0284c7;
  --accent-light: #f0f9ff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success: #059669;
  --success-light: #ecfdf5;
  --danger: #e11d48;
  --danger-light: #fff1f2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --font-sans: 'Inter', sans-serif;
  --font-title: 'Outfit', sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-indigo: 0 4px 14px rgba(13, 148, 136, 0.15);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* LAYOUT CONTAINER */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR STYLES */
.app-sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  padding: 24px 16px;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 32px 8px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 24px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.brand-logo svg {
  width: 24px;
  height: 24px;
}

.heartbeat {
  stroke-dasharray: 100;
  animation: pulsePath 3s linear infinite;
}

@keyframes pulsePath {
  0% { stroke-dashoffset: 100; }
  100% { stroke-dashoffset: 0; }
}

.brand-text h1 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #ffffff;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--sidebar-text);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.menu-item:hover {
  background-color: var(--sidebar-active-bg);
  color: #ffffff;
}

.menu-item.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: inset 4px 0 0 var(--sidebar-active-text);
}

.menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-status {
  padding-top: 16px;
  border-top: 1px solid #1e293b;
}

.verifactu-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(5, 150, 105, 0.1);
  border: 1px solid rgba(5, 150, 105, 0.2);
  color: #34d399;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #34d399;
  border-radius: 50%;
  position: relative;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #34d399;
  animation: pulseRing 1.5s infinite ease-out;
  left: 0;
  top: 0;
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* APP CONTENT CONTAINER */
.app-content-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* HEADER */
.app-header {
  height: 70px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
}

#screen-title {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--text-dark);
  font-size: 1.5rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.user-role {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(13, 148, 136, 0.2);
}

.user-avatar svg {
  width: 24px;
  height: 24px;
}

/* CONTENT SCROLLABLE */
.app-content {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  position: relative;
}

/* SCREEN SECTIONS */
.screen-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.screen-section.active {
  display: block;
}

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

/* GENERAL BLOCKS & CARDS */
.glass-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.card-header {
  margin-bottom: 20px;
}

.card-header h5 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--text-dark);
  font-weight: 600;
}

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

.divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 20px 0;
  width: 100%;
}

/* DASHBOARD BANNER */
.dashboard-banner {
  background: linear-gradient(135deg, #0d9488 0%, #0369a1 100%);
  border-radius: var(--radius-lg);
  padding: 32px;
  color: #ffffff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.dashboard-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.banner-content h3 {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.banner-content p {
  font-size: 1rem;
  opacity: 0.9;
  max-width: 600px;
}

/* METRICS GRID */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon svg {
  width: 24px;
  height: 24px;
}

.metric-icon.val-green {
  background-color: var(--success-light);
  color: var(--success);
}

.metric-icon.val-blue {
  background-color: var(--accent-light);
  color: var(--accent);
}

.metric-icon.val-purple {
  background-color: #f5f3ff;
  color: #7c3aed;
}

.metric-details {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

.metric-value {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-top: 2px;
}

/* DASHBOARD BLOCKS */
.dashboard-blocks {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
  min-width: 320px;
}

.quick-actions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-iconic {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 16px 20px !important;
  text-align: left;
  border-radius: var(--radius-md);
}

.btn-svg {
  width: 20px;
  height: 20px;
}

.recent-invoices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recent-inv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.recent-inv-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
}

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

.recent-inv-number {
  font-weight: 600;
  font-size: 0.9rem;
}

.recent-inv-client {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.recent-inv-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.recent-inv-amount {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.recent-inv-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-icon-lg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 12px;
}

/* GRID LAYOUT FOR 2 PANEL VIEWS */
.grid-layout-2 {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 24px;
  align-items: start;
}

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

/* TABLES STYLES */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.list-box {
  max-height: 450px;
  overflow-y: auto;
}

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

.data-table th {
  background-color: var(--bg-primary);
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background-color: rgba(241, 245, 249, 0.5);
}

.actions-col {
  width: 110px;
  text-align: right;
}

.price-col {
  text-align: right;
  font-weight: 600;
}

.btn-table-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
  width: 100%;
}

.search-bar-inline {
  margin-bottom: 16px;
}

.search-bar-inline input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  transition: var(--transition);
}

.search-bar-inline input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* FORMS STYLES */
.responsive-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.col-12 { width: 100%; }
.col-6 { width: calc(50% - 8px); }
.col-4 { width: calc(33.333% - 10.6px); }

@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    gap: 16px;
  }
  .col-6, .col-4 {
    width: 100%;
  }
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-dark);
  font-family: var(--font-sans);
  background-color: #ffffff;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
  resize: vertical;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-indigo);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(2, 132, 199, 0.2);
}

.btn-secondary:hover {
  background-color: #e0f2fe;
}

.btn-light {
  background-color: var(--bg-primary);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}

.btn-light:hover {
  background-color: var(--border-color);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #047857;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 14px;
  height: 14px;
}

.btn-icon:hover {
  color: #ffffff;
}

.btn-icon.edit-icon:hover {
  background-color: var(--accent);
  border-color: var(--accent);
}

.btn-icon.delete-icon:hover {
  background-color: var(--danger);
  border-color: var(--danger);
}

.w-full {
  width: 100%;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }

/* CALENDAR LAYOUT & GRID */
.calendar-container-layout {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 24px;
  align-items: start;
}

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

.calendar-card {
  padding: 24px;
}

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

.calendar-header h4 {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
}

.calendar-nav-btn {
  background: none;
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dark);
  transition: var(--transition);
}

.calendar-nav-btn:hover {
  background-color: var(--bg-primary);
  border-color: var(--primary);
  color: var(--primary);
}

.calendar-nav-btn svg {
  width: 16px;
  height: 16px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-day-cell {
  aspect-ratio: 1.1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  background-color: #ffffff;
  transition: var(--transition);
  min-height: 75px;
}

.calendar-day-cell:hover:not(.other-month) {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.calendar-day-cell.other-month {
  background-color: rgba(241, 245, 249, 0.3);
  border-color: rgba(226, 232, 240, 0.5);
  color: var(--text-muted);
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.calendar-day-cell.today {
  border-color: var(--accent);
  background-color: var(--accent-light);
}

.calendar-day-cell.today .day-number {
  color: var(--accent);
  font-weight: 700;
}

.calendar-day-cell.selected {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-light);
  transform: scale(0.98);
}

.calendar-day-cell.worked {
  border-color: var(--success);
  background-color: var(--success-light);
}

.day-number {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
}

.calendar-day-cell.worked .day-number {
  color: var(--success);
}

.day-services-badges {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  overflow: hidden;
  max-height: 42px;
}

.day-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background-color: rgba(13, 148, 136, 0.15);
  color: var(--primary);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
}

.day-badge.carto-color {
  background-color: rgba(2, 132, 199, 0.15);
  color: var(--accent);
}

.day-badge.other-color {
  background-color: rgba(124, 58, 237, 0.15);
  color: #7c3aed;
}

.day-price-indicator {
  font-size: 0.725rem;
  font-weight: 700;
  text-align: right;
  color: var(--success);
  margin-top: 2px;
}

/* DAY DETAILS SIDEBAR */
.day-details-card {
  padding: 24px;
  min-height: 380px;
}

.border-bottom {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.day-details-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-services-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.day-service-item-info {
  display: flex;
  flex-direction: column;
}

.day-service-item-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.day-service-item-qty {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.day-service-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.day-service-item-price {
  font-weight: 700;
  font-size: 0.875rem;
}

.day-services-total {
  margin-top: 8px;
  padding: 12px;
  background-color: var(--primary-light);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(13, 148, 136, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
}

.day-services-editor {
  margin-top: 16px;
  padding-top: 16px;
}

.day-services-editor h6 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* INVOICE CREATOR LAYOUT */
.invoice-creator-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 32px;
  align-items: start;
}

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

.invoice-config-panel {
  padding: 20px;
}

.import-calendar-section {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-md);
}

.import-calendar-section h6 {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

/* A4 INVOICE PREVIEW */
.invoice-preview-container {
  overflow-x: auto;
  padding-bottom: 20px;
  display: flex;
  justify-content: center;
}

.invoice-a4 {
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 15mm;
  background-color: #ffffff;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  color: #1e293b;
  position: relative;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12mm;
}

.emitter-details-box {
  flex-grow: 1;
}

.emitter-name-preview {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--sidebar-bg);
  margin-bottom: 3mm;
}

.emitter-details-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1mm;
}

.invoice-title-box {
  text-align: right;
  min-width: 240px;
}

.invoice-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4mm;
  letter-spacing: 0.05em;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5mm 4mm;
  font-size: 0.8rem;
  text-align: left;
}

.meta-label {
  color: var(--text-muted);
  font-weight: 600;
}

.meta-val {
  color: var(--text-dark);
  font-weight: 700;
  text-align: right;
}

.invoice-divider {
  height: 1px;
  background-color: #cbd5e1;
  margin-bottom: 8mm;
  width: 100%;
}

.invoice-client-box {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4mm 5mm;
  margin-bottom: 8mm;
  width: 100%;
}

.client-box-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 2mm;
}

.client-name-preview {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2mm;
}

.invoice-client-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.5mm;
}

/* INVOICE ITEMS TABLE */
.invoice-table-wrapper {
  flex-grow: 1;
  margin-bottom: 10mm;
}

.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.invoice-items-table th {
  border-bottom: 2px solid #94a3b8;
  color: var(--text-dark);
  font-weight: 700;
  padding: 3mm 2mm;
  text-align: left;
}

.invoice-items-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 3mm 2mm;
  color: #334155;
  line-height: 1.4;
}

.invoice-items-table tbody tr:last-child td {
  border-bottom: 2px solid #cbd5e1;
}

.col-date {
  width: 75px;
}

.col-desc {
  text-align: left;
}

.col-qty {
  width: 45px;
}

.col-price {
  width: 90px;
}

.col-total {
  width: 95px;
  font-weight: 600;
}

/* INVOICE BOTTOM */
.invoice-bottom-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 8mm;
  margin-top: auto;
  align-items: start;
}

.bottom-left-panel {
  display: flex;
  flex-direction: column;
  gap: 4mm;
}

.payment-method-box {
  background-color: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 3.5mm;
  font-size: 0.75rem;
  line-height: 1.5;
  border: 1px solid var(--border-color);
}

.legal-exemption-box {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-style: italic;
}

.bottom-right-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6mm;
}

.invoice-totals-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2.5mm;
  font-size: 0.8rem;
}

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

.totals-row span:first-child {
  color: var(--text-muted);
  font-weight: 600;
}

.totals-row span:last-child {
  color: var(--text-dark);
  font-weight: 700;
}

.total-final-row {
  border-top: 1.5px solid #cbd5e1;
  padding-top: 3mm;
  font-size: 1.05rem;
}

.total-final-row span:first-child {
  color: var(--sidebar-bg) !important;
  font-weight: 800;
}

.total-final-row span:last-child {
  color: var(--primary) !important;
  font-weight: 800;
}

/* VERIFACTU CODE QR PREVIEW */
.verifactu-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  padding: 4mm;
  background-color: #ffffff;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 220px;
}

.verifactu-title-top {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #334155;
  margin-bottom: 2mm;
  text-align: center;
  width: 100%;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5mm;
}

.verifactu-qr-box {
  background-color: #ffffff;
  padding: 1mm;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* QR Canvas size rendering control */
#verifactu-qr-image canvas, 
#verifactu-qr-image img {
  display: block;
  width: 32mm !important;
  height: 32mm !important;
}

.verifactu-text-bottom {
  font-size: 0.55rem;
  font-weight: 600;
  color: #475569;
  text-align: center;
  line-height: 1.3;
  margin-top: 2.5mm;
  border-top: 1px dashed var(--border-color);
  padding-top: 2mm;
  width: 100%;
}

/* TOAST NOTIFICATION */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--sidebar-bg);
  color: #ffffff;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast-icon {
  background-color: var(--primary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
}

/* SETTINGS & BACKUP STYLES */
.backup-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.import-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 2px dashed var(--border-color);
  width: 100%;
  padding: 32px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.import-label:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
  color: var(--primary);
}

.import-label svg {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}

.card-border-danger {
  border-color: rgba(225, 29, 72, 0.3) !important;
}

.text-sm { font-size: 0.8rem; }

/* PRINT STYLES */
@media print {
  body {
    background-color: #ffffff;
    color: #000000;
    min-height: auto;
  }
  
  .app-container {
    height: auto;
    overflow: visible;
  }
  
  .app-sidebar, 
  .app-header, 
  .invoice-config-panel,
  #screen-title,
  .no-print {
    display: none !important;
  }
  
  .app-content-wrapper {
    height: auto;
    overflow: visible;
  }

  .app-content {
    padding: 0 !important;
    overflow-y: visible;
  }
  
  .screen-section {
    display: none !important;
  }
  
  .screen-section#screen-invoice-creator {
    display: block !important;
  }
  
  .invoice-creator-layout {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .invoice-preview-container {
    padding-bottom: 0 !important;
  }

  .invoice-a4 {
    width: 210mm !important;
    height: 297mm !important;
    border: none !important;
    box-shadow: none !important;
    padding: 10mm 10mm !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  
  /* Ensure exact styling and sizes on physical paper */
  #verifactu-qr-image canvas,
  #verifactu-qr-image img {
    width: 35mm !important;
    height: 35mm !important;
  }
}

/* ==========================================================================
   PWA & FIREBASE AUTHENTICATION SCREEN & STATE STYLES
   ========================================================================== */

/* AUTH OVERLAY CONTAINER */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.75); /* Dark slate semi-transparent */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999; /* Higher than everything else */
  animation: fadeInAuth 0.3s ease-out;
}

@keyframes fadeInAuth {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* AUTHENTICATION CARD */
.auth-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  animation: popInAuth 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popInAuth {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo-box {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
}

.auth-logo-svg {
  width: 32px;
  height: 32px;
}

.auth-header h3 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sidebar-bg);
  margin-bottom: 6px;
}

.auth-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* AUTH TABS */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
  gap: 16px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0;
  font-family: var(--font-sans);
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; /* Overlay on top of container border */
}

.auth-tab:hover {
  color: var(--text-dark);
}

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

/* FORMS DISPLAY */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.auth-form.active {
  display: flex;
}

.auth-switch-text {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.auth-switch-text a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch-text a:hover {
  text-decoration: underline;
}

/* CLOUD SYNC STATE BADGES (SIDEBAR) */
.cloud-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: var(--transition);
}

.cloud-badge.offline {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}

.cloud-badge.offline .cloud-dot {
  background-color: #94a3b8;
}

.cloud-badge.syncing {
  background-color: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.2);
  color: var(--accent);
}

.cloud-badge.syncing .cloud-dot {
  background-color: var(--accent);
  animation: pulseRing 1.2s infinite ease-out;
}

.cloud-badge.online {
  background-color: var(--primary-light);
  border-color: rgba(13, 148, 136, 0.2);
  color: var(--primary);
}

.cloud-badge.online .cloud-dot {
  background-color: var(--primary);
  position: relative;
}

.cloud-badge.online .cloud-dot::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--primary);
  animation: pulseRing 2s infinite ease-out;
  left: 0;
  top: 0;
}

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

/* SIDEBAR USER PROFILE PANEL */
.sidebar-profile {
  margin-top: 12px;
  padding: 12px;
  background-color: var(--sidebar-active-bg);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-email-text {
  font-size: 0.725rem;
  color: var(--sidebar-text);
  word-break: break-all;
  font-weight: 500;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid rgba(225, 29, 72, 0.3);
  color: var(--danger);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

.btn-logout:hover {
  background-color: rgba(225, 29, 72, 0.1);
  color: #ff4d6d;
}

.logout-icon-svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* ANNUAL CHART STYLES */
.annual-chart-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 220px;
  padding: 16px 8px 8px 8px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-top: 12px;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  min-width: 32px;
}

.chart-bar-wrapper {
  width: 100%;
  height: calc(100% - 24px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
}

.chart-bar {
  width: 16px;
  background: linear-gradient(to top, var(--primary), var(--accent));
  border-radius: 4px 4px 0 0;
  height: 0%;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.chart-bar-item:hover .chart-bar {
  filter: brightness(1.1);
  box-shadow: 0 0 12px rgba(13, 148, 136, 0.4);
}

.chart-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -8px) scale(0.9);
  background-color: var(--sidebar-bg);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.chart-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px;
  border-style: solid;
  border-color: var(--sidebar-bg) transparent transparent transparent;
}

.chart-bar-item:hover .chart-tooltip {
  opacity: 1;
  transform: translate(-50%, -8px) scale(1);
}

.chart-bar-label {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
  text-transform: uppercase;
}

.chart-bar-item.current-month .chart-bar-label {
  color: var(--primary);
  font-weight: 700;
}

.mb-4 {
  margin-bottom: 24px !important;
}

/* Hide hamburger menu toggle by default on desktop */
.btn-menu-toggle {
  display: none;
}

/* ==========================================================================
   RESPONSIVE LAYOUT (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 991px) {
  body {
    overflow-x: hidden;
  }

  /* Hamburger Toggle Button Styles */
  .btn-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
  }
  
  .btn-menu-toggle:hover {
    background-color: var(--border-color);
  }
  
  .btn-menu-toggle svg {
    width: 24px;
    height: 24px;
  }

  /* Sidebar behavior on mobile */
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    box-shadow: 10px 0 25px rgba(0, 0, 0, 0.15);
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }

  /* Header adjustments */
  .app-header {
    padding: 0 16px;
    justify-content: flex-start;
  }
  
  .header-search {
    flex-grow: 1;
  }
  
  #screen-title {
    font-size: 1.2rem;
  }
  
  .user-info {
    display: none; /* Hide user name text on mobile to save space */
  }

  /* Content area padding */
  .app-content {
    padding: 16px;
  }

  /* Stack grid layouts to single column */
  .grid-layout-2, 
  .grid-layout-3, 
  .metrics-grid, 
  .invoice-creator-layout, 
  .calendar-container-layout {
    grid-template-columns: 1fr !important;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* Calendar Sidebar adjustments */
  .day-details-card {
    margin-top: 0;
  }

  /* Invoice A4 preview: scale down and scroll horizontally to prevent layout breaking */
  .invoice-preview-container {
    overflow-x: auto;
    padding: 8px 4px;
    display: flex;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  
  .invoice-a4 {
    transform: scale(0.48); /* Scale to fit phone screens better */
    transform-origin: top left;
    min-width: 800px;
    margin-bottom: -400px; /* Offset spacing due to scaling */
  }
  
  /* Tables horizontal scroll */
  .table-container {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 500px;
  }
}

