/* ==========================================================================
   EA-Buchhaltung - Design System (nelke.com)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..24,400,0,0&display=swap');

:root {
  --font-heading: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Brand Colors from nelke.com */
  --nelke-red: #E50013;
  --nelke-teal: #2B9F9F;
  --nelke-gray: #7C7C7C;
  --gradient-primary: linear-gradient(135deg, #E50013 0%, #2B9F9F 100%);
  --gradient-accent: linear-gradient(135deg, #2B9F9F 0%, #7C7C7C 100%);

  /* 2-Tone Gray Material Icons */
  --icon-gray-primary: #94a3b8;
  --icon-gray-secondary: #64748b;
  --icon-gray-active: #e2e8f0;

  /* Status Colors */
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  /* Dark Theme (Default) */
  --bg-base: #090e1a;
  --bg-surface: #11192b;
  --bg-card: rgba(17, 25, 43, 0.85);
  --bg-card-hover: rgba(23, 33, 56, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(229, 0, 19, 0.35);

  --text-primary: #f3f4f6;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme */
[data-theme="light"] {
  --bg-base: #fafafa;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --border-color: rgba(15, 23, 42, 0.08);
  --border-glow: rgba(229, 0, 19, 0.2);

  --icon-gray-primary: #64748b;
  --icon-gray-secondary: #94a3b8;
  --icon-gray-active: #1e293b;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
}

/* Material Symbols Outlined (2-Color Gray) */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  color: var(--icon-gray-primary);
  user-select: none;
  transition: color 0.2s ease;
}

.icon-sub,
.dropdown-arrow {
  color: var(--icon-gray-secondary) !important;
}

a:hover .material-symbols-outlined,
.btn:hover .material-symbols-outlined,
.nav-dropdown-item:hover .material-symbols-outlined,
.nav-dropdown-toggle:hover .material-symbols-outlined,
.active .material-symbols-outlined,
.active-parent .material-symbols-outlined,
.nav-links a.active .material-symbols-outlined,
.nav-links a:hover .material-symbols-outlined {
  color: var(--icon-gray-active) !important;
}

/* Base Styles */
html {
  font-size: 14px; /* Crisp, data-dense base size */
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-font {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* Header & Navigation */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  object-fit: contain;
  filter: drop-shadow(0 2px 8px var(--border-glow));
}

.brand-logo-badge {
  background: var(--gradient-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  box-shadow: 0 2px 8px var(--border-glow);
}

.brand-titles h1 {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
}

.brand-titles span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.nav-links a,
.nav-dropdown-toggle {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  border: 1px solid transparent;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  line-height: 1.2;
}

.nav-links a:hover,
.nav-links a.active,
.nav-dropdown-toggle:hover,
.nav-item-dropdown.open .nav-dropdown-toggle,
.nav-dropdown-toggle.active-parent {
  background: rgba(229, 0, 19, 0.08);
  color: var(--nelke-red);
  border-color: rgba(229, 0, 19, 0.15);
}

.nav-item-dropdown {
  position: relative;
  padding-bottom: 6px;
  margin-bottom: -6px;
}

.dropdown-arrow {
  font-size: 17px !important;
  transition: transform 0.2s ease;
  margin-left: 0.1rem;
}

.nav-item-dropdown:hover .dropdown-arrow,
.nav-item-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 1000;
  backdrop-filter: blur(12px);
  animation: fadeInMenu 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Invisible hover bridge to prevent menu from closing when moving cursor across the gap */
.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 14px;
  background: transparent;
}

@keyframes fadeInMenu {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-item-dropdown:hover .nav-dropdown-menu,
.nav-item-dropdown.open .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-dropdown-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color);
}

.nav-dropdown-item.active {
  background: rgba(229, 0, 19, 0.08);
  border-left: 3px solid var(--nelke-red);
}

.nav-dropdown-item .item-text {
  display: flex;
  flex-direction: column;
}

.nav-dropdown-item .item-text .title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-dropdown-item .item-text .desc {
  font-size: 0.70rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Year selector */
.year-badge-select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  outline: none;
}

/* App Main Content */
main.app-content {
  flex: 1;
  padding: 1.5rem 1.25rem 5.5rem; /* bottom padding for mobile bar */
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Tab Views */
.tab-view {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-view.active {
  display: block;
}

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

/* Cards & Grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  transition: var(--transition);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header-sm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.card-title-sm {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-value.profit { color: var(--color-success); }
.card-value.loss { color: var(--color-danger); }
.card-value.vat { color: var(--nelke-teal); }
.card-value.accent { color: var(--nelke-red); }

.card-subtext {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Banner / VAT Status Card */
.vat-status-box {
  background: linear-gradient(135deg, rgba(43, 159, 159, 0.15) 0%, rgba(229, 0, 19, 0.12) 100%);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.vat-status-info h3 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.vat-status-metrics {
  display: flex;
  gap: 1.5rem;
}

.vat-stat-item {
  display: flex;
  flex-direction: column;
}

.vat-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.vat-stat-num {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

/* Action Buttons & Forms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--nelke-red);
  color: #fff;
  box-shadow: 0 2px 6px rgba(229, 0, 19, 0.3);
}

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

.btn-teal {
  background: var(--nelke-teal);
  color: #fff;
  box-shadow: 0 2px 6px rgba(43, 159, 159, 0.3);
}

.btn-teal:hover {
  background: #238585;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

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

table.data-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  white-space: nowrap;
}

table.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-income {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

.badge-expense {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.badge-vat {
  background: rgba(43, 159, 159, 0.15);
  color: var(--nelke-teal);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.modal-dialog-split {
  max-width: 960px;
  width: 96%;
}

.ai-import-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, rgba(43, 159, 159, 0.12) 0%, rgba(229, 0, 19, 0.08) 100%);
  border: 1px solid rgba(43, 159, 159, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.trans-split-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 820px) {
  .trans-split-grid {
    grid-template-columns: 360px 1fr;
  }
}

.trans-preview-box {
  background: var(--bg-base);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 380px;
  height: 100%;
  max-height: 520px;
  overflow: hidden;
  position: relative;
}

.trans-preview-box.has-preview {
  border-style: solid;
}

.trans-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.trans-preview-box iframe {
  width: 100%;
  height: 100%;
  border: none;
  min-height: 400px;
}

@keyframes spinAnim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  animation: spinAnim 1s linear infinite;
  display: inline-block;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 1.2rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.form-control {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.84rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--nelke-red);
  box-shadow: 0 0 0 2px rgba(229, 0, 19, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

/* Mobile Bottom Navigation Bar */
nav.mobile-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 0.5rem 0;
  justify-content: space-around;
  backdrop-filter: blur(12px);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.mobile-nav-item.active {
  color: var(--nelke-red);
}

.mobile-nav-item svg {
  width: 22px;
  height: 22px;
}

/* Responsive media queries */
@media (max-width: 768px) {
  html {
    font-size: 13px; /* Compact mobile typography */
  }
  .nav-links {
    display: none; /* hidden on mobile, bottom bar is used */
  }
  nav.mobile-nav-bar {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: space-around;
    padding: 0.35rem 0.25rem;
    scrollbar-width: none;
  }
  nav.mobile-nav-bar::-webkit-scrollbar {
    display: none;
  }
  .mobile-nav-item {
    padding: 0.2rem 0.35rem;
    font-size: 0.65rem;
  }
  .mobile-nav-item .material-symbols-outlined {
    font-size: 19px;
  }
  .app-header {
    padding: 0.5rem 0.75rem;
  }
  .brand-logo-img {
    width: 32px;
    height: 32px;
  }
  .brand-titles h1 {
    font-size: 0.95rem;
  }
  .brand-titles span {
    font-size: 0.65rem;
  }
  main.app-content {
    padding: 0.75rem 0.65rem 4.5rem;
  }
  .card {
    padding: 0.85rem;
    border-radius: var(--radius-sm);
  }
  .card-value {
    font-size: 1.3rem;
  }
  table.data-table th, table.data-table td {
    padding: 0.45rem 0.55rem;
    font-size: 0.78rem;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
    gap: 0.6rem !important;
  }
  .form-control {
    font-size: 0.82rem;
    padding: 0.4rem 0.55rem;
  }
  .btn {
    padding: 0.38rem 0.7rem;
    font-size: 0.8rem;
  }
  .btn-sm {
    padding: 0.22rem 0.45rem;
    font-size: 0.74rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 12px; /* High information density on small smartphone screens */
  }
  .app-header {
    padding: 0.4rem 0.6rem;
  }
  .brand-wrapper {
    gap: 0.45rem;
  }
  .brand-logo-img {
    width: 28px;
    height: 28px;
  }
  .brand-titles h1 {
    font-size: 0.88rem;
  }
  .brand-titles span {
    display: none; /* Hide subtitle on tiny screens to save height */
  }
  .header-actions {
    gap: 0.35rem;
  }
  .year-badge-select {
    padding: 0.25rem 0.45rem;
    font-size: 0.75rem;
  }
  .btn-icon {
    width: 30px;
    height: 30px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.45rem !important;
  }
  .stat-card {
    padding: 0.55rem !important;
  }
  .stat-label {
    font-size: 0.65rem !important;
  }
  .stat-value {
    font-size: 1.15rem !important;
  }
  .view-header {
    margin-bottom: 0.75rem !important;
  }
  .view-header h2 {
    font-size: 1.05rem;
  }
  .view-header p.subtitle {
    font-size: 0.72rem;
  }
  table.data-table th, table.data-table td {
    padding: 0.35rem 0.45rem;
    font-size: 0.74rem;
  }
  .modal-dialog {
    margin: 0.5rem;
    padding: 0.85rem;
  }
}
