:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #0f172a;
  --background: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: 0.2s ease-in-out;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  scroll-behavior: smooth;
}
body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: block;
}

/* Loader */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.loader-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loader-text {
  margin-top: 15px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Auth */
.auth-container {
  width: min(100% - 32px, 400px);
  margin: 80px auto;
  padding: 40px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.auth-header {
  text-align: center;
  margin-bottom: 30px;
}
.auth-header i {
  font-size: 48px;
  color: var(--primary);
}
.auth-header h1 {
  margin-top: 10px;
  font-size: 1.5rem;
  font-weight: 700;
}
.auth-header p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
  font-size: 0.95rem;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
textarea {
  min-height: 100px;
  resize: vertical;
}
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
  background: var(--border);
  color: var(--text);
  text-decoration: none;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(0.95);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}
.btn-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: white;
}
.btn-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}
.btn-warning:hover:not(:disabled) {
  background: var(--warning);
  color: white;
}
.btn-block {
  width: 100%;
  padding: 12px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--muted);
  transition: var(--transition);
}
.icon-btn:hover {
  background: var(--border);
  color: var(--text);
}
.icon-btn.text-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* Layout & Topbar */
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.topbar-actions {
  display: flex;
  gap: 8px;
}
.view {
  display: none;
  padding: 20px;
  padding-bottom: 90px;
  animation: fadeIn 0.3s ease;
}
.view.active-view {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cards & Stats */
.cards,
.analytics-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-card strong {
  font-size: 1.02rem;
  color: var(--text);
  font-weight: 700;
}
.dashboard-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.dashboard-card i {
  font-size: 2.5rem;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 12px;
  border-radius: 12px;
}
.dashboard-card h4 {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Lists & Badges */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}
.card.list-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.item-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.item-meta {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.nav-btn .badge {
  position: absolute;
  top: 0;
  right: 0;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}
.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}
.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

/* Ledger & PDF Styles */
.ledger-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.ledger-entry:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.ledger-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ledger-type {
  font-weight: 600;
  text-transform: capitalize;
}
.ledger-date {
  font-size: 0.8rem;
  color: var(--muted);
}
.ledger-debit {
  color: var(--danger);
  font-weight: 700;
  font-family: monospace;
  font-size: 1.05rem;
}
.ledger-credit {
  color: var(--success);
  font-weight: 700;
  font-family: monospace;
  font-size: 1.05rem;
}
#pdfPrintArea {
  background: white;
  padding: 20px;
  border-radius: 8px;
  color: #000;
}
.report-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

/* Profile & Modals */
.profile-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  font-size: 2.5rem;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal.show {
  display: flex;
  opacity: 1;
}
.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}
.modal.show .modal-content {
  transform: translateY(0);
}
.modal-content.large {
  max-width: 700px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-btn i {
  font-size: 1.4rem;
  margin-bottom: 2px;
}
.nav-btn.active,
.nav-btn:hover {
  color: var(--primary);
}

/* Toasts & States */
#toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--secondary);
  color: white;
  padding: 12px 24px;
  border-radius: 99px;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 9999;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.success {
  background: var(--success);
}
#toast.error {
  background: var(--danger);
}
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}
.empty-state i {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
.loading::after {
  content: "";
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Utilities */
.hidden {
  display: none !important;
}
.text-danger {
  color: var(--danger) !important;
}
.text-center {
  text-align: center !important;
}
.text-muted {
  color: var(--muted) !important;
}
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.align-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 16px;
}
.flex-1 {
  flex: 1;
}
.mb-2 {
  margin-bottom: 8px;
}
.mb-3 {
  margin-bottom: 16px;
}

.flex-wrap {
  flex-wrap: wrap;
}

/* Desktop Responsiveness */
@media (min-width: 768px) {
  #main-screen {
    display: flex;
    padding-left: 240px;
  }
  .view {
    padding: 32px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
  }
  .bottom-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    height: 100vh;
    border-right: 1px solid var(--border);
    border-top: none;
    flex-direction: column;
    justify-content: flex-start;
    padding: 24px 12px;
    gap: 8px;
    background: var(--surface);
  }
  .nav-btn {
    flex: none;
    height: 48px;
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 16px;
    gap: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    position: relative;
  }
  .nav-btn i {
    font-size: 1.25rem;
    margin-bottom: 0;
  }
  .nav-btn.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-weight: 600;
  }
}

/* Custom Dialogue Layout Utilities */
.width-100 {
  width: 100%;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 16px;
}
.justify-end {
  justify-content: flex-end;
}

#invoicePrintArea {
  width: max-content;
}
#invoicePrintArea > div {
  width: 100%;
  flex-shrink: 0;
  gap: 15px;
}

/* Settings Tabs & i18n Styles */
.settings-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
  overflow-x: auto; 
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}
.tab-pane.active {
  display: block;
}
.settings-card {
  max-width: 650px;
}
.lang-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  border-radius: 4px;
  margin-left: 6px;
}
