:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #06b6d4;
  --bg-dark: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --accent-green: #10b981;
  --accent-red: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: var(--text-main);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

/* Header Banner - Standard Desktop UI */
.header-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px 20px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-title img {
  height: 55px;
  width: auto;
  border-radius: 6px;
}

.header-title h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(90deg, #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Buttons - Desktop UI */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.action-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.85rem !important;
  border-radius: 6px !important;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.6);
}

.btn-secondary {
  background: #334155;
  color: #ffffff !important;
  border: 1px solid #475569;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

/* Cards - Desktop UI */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  transition: background 0.3s, border-color 0.3s;
}

[data-theme="light"] .form-control {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
}

[data-theme="light"] .form-group label {
  color: #334155;
  font-weight: 700;
}

[data-theme="light"] .header-banner {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .header-banner h1 {
  color: #0f172a;
}

[data-theme="light"] .header-banner p {
  color: #64748b;
}

[data-theme="light"] .custom-table th {
  background: #f1f5f9;
  color: #334155;
  border-bottom: 2px solid #cbd5e1;
}

[data-theme="light"] .custom-table td {
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
}

[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="text"].date-picker,
[data-theme="light"] .date-input-wrapper,
[data-theme="light"] .date-input-wrapper input,
[data-theme="light"] .date-input-wrapper input[type="date"] {
  background-color: #ffffff !important;
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .calendar-icon-btn,
[data-theme="light"] .calendar-icon-btn svg {
  background: transparent !important;
  stroke: #475569 !important;
  color: #475569 !important;
}

.result-summary,
.summary-box {
  background: var(--card-bg) !important;
  backdrop-filter: blur(10px) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 12px !important;
  padding: 16px 20px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

.summary-row {
  border-bottom: none !important;
  padding: 8px 0;
}

[data-theme="light"] .summary-row strong {
  color: #0f172a !important;
}

[data-theme="light"] .summary-row.total-row {
  border-top: 2px solid #6366f1 !important;
  border-bottom: none !important;
}

[data-theme="light"] .summary-row.total-row strong,
[data-theme="light"] .summary-row.total-row span {
  color: #4f46e5 !important;
}

[data-theme="light"] .section-title-label {
  color: #4338ca !important;
}

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

.card-header h3 {
  font-size: 1.1rem;
  color: #c7d2fe;
  font-weight: 700;
}

/* Theme CSS Variables */
:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-label: #a5b4fc;
  --input-bg: #1e293b;
  --input-border: #475569;
  --table-header-bg: rgba(15, 23, 42, 0.6);
  --table-row-hover: rgba(51, 65, 85, 0.4);
}

[data-theme="light"] {
  --bg-gradient: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-label: #475569;
  --input-bg: #f8fafc;
  --input-border: #cbd5e1;
  --table-header-bg: #f1f5f9;
  --table-row-hover: #f8fafc;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 15px;
}

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

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a5b4fc;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  background: #1e293b;
  border: 1px solid #475569;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control option {
  background: #0f172a;
  color: #ffffff;
}

.form-control:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.3);
}

/* Date Input Wrapper - Universal Perfect Overlay */
.date-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

.date-input-wrapper input[type="date"] {
  width: 100% !important;
  padding-right: 36px !important;
  color: #ffffff !important;
  background-color: #1e293b !important;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  min-height: 38px;
}

.date-input-wrapper .calendar-icon-btn {
  position: absolute;
  right: 10px;
  pointer-events: none;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

/* Table - Desktop UI */
.table-responsive {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.custom-table th, 
.custom-table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.custom-table th {
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.custom-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.badge {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
}

.badge-yes {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.badge-no {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* Result Financial Summary Box */
.result-summary {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #4338ca;
  border-radius: 10px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.summary-row.total-row {
  font-size: 1.15rem;
  font-weight: 700;
  color: #38bdf8;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

/* MOBILE RESPONSIVE MEDIA QUERIES (<768px) */
@media screen and (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  .header-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 15px;
    text-align: center;
  }
  
  .header-title {
    flex-direction: column;
    text-align: center;
  }

  .header-controls {
    flex-direction: column;
    width: 100%;
    gap: 8px !important;
  }

  .header-profile-badge {
    width: 100%;
    text-align: center !important;
    justify-content: center;
    background: rgba(30, 41, 59, 0.95) !important;
    padding: 8px 12px !important;
  }

  .header-action-btns {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px !important;
  }

  .header-action-btns .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    font-size: 0.85rem;
    padding: 11px;
    box-sizing: border-box;
  }

  /* Filter Buttons Grid for Mobile */
  .filter-btn-group {
    display: flex;
    width: 100%;
    gap: 6px;
    margin-top: 10px;
  }

  .filter-btn-group .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    font-size: 0.75rem !important;
    padding: 9px 4px !important;
    white-space: nowrap;
    box-sizing: border-box;
  }

  /* Mobile Table to Glassmorphic Card View Converter */
  .custom-table {
    display: block;
    width: 100%;
  }

  .custom-table thead {
    display: none; /* Hide desktop table header on mobile */
  }

  .custom-table tbody {
    display: block;
    width: 100%;
  }

  .custom-table tr {
    display: block;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid #334155;
    border-radius: 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }

  .custom-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    border-bottom: 1px dashed rgba(71, 85, 105, 0.5);
    font-size: 0.82rem;
  }

  .custom-table td:last-child {
    border-bottom: none;
    padding-top: 10px;
    justify-content: flex-end;
  }

  .custom-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #94a3b8;
    font-size: 0.76rem;
    text-transform: uppercase;
  }

  .action-btn-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.95rem !important;
    padding: 0 !important;
  }

/* MOBILE APP RESPONSIVE OPTIMIZATIONS (<768px) */
@media screen and (max-width: 768px) {
  body {
    padding: 8px 6px;
  }

  .header-banner {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 10px !important;
    padding: 12px 10px !important;
  }

  .header-title {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 6px !important;
  }

  .header-banner .btn {
    width: 80% !important;
    margin: 0 auto !important;
    justify-content: center !important;
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
  }

  .header-title img {
    height: 45px !important;
    width: auto !important;
  }

  .header-title h1 {
    font-size: 1.05rem !important;
  }

  .header-title p {
    font-size: 0.72rem !important;
  }

  /* Form Fields One-By-One Stacking */
  .grid-3 {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .form-group {
    width: 100% !important;
  }

  /* Reduced Compact Buttons for Mobile */
  .btn {
    padding: 6px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
  }

  /* Date Wrapper Mobile Touch Fix */
  .date-input-wrapper {
    width: 100% !important;
    display: flex !important;
  }

  .date-input-wrapper input[type="date"] {
    font-size: 0.82rem !important;
    padding: 7px 32px 7px 10px !important;
    min-height: 36px !important;
  }

  /* Expense Items Card View on Mobile */
  .custom-table thead {
    display: none;
  }

  .custom-table, 
  .custom-table tbody, 
  .custom-table tr, 
  .custom-table td {
    display: block;
    width: 100%;
  }

  .custom-table tr {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  }

  .custom-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #334155;
    text-align: right;
  }

  .custom-table td:last-child {
    border-bottom: none;
    padding-top: 8px;
    justify-content: flex-end;
  }

  .custom-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #a5b4fc;
    font-size: 0.72rem;
    text-transform: uppercase;
    float: left;
  }

  .custom-table td[data-label="Action"]::before {
    content: "" !important;
  }

  .custom-table td input.form-control,
  .custom-table td select.form-control,
  .custom-table td .date-input-wrapper {
    max-width: 65% !important;
    width: 65% !important;
  }

  .attach-badge-btn {
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
  }

  .action-btn-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.75rem !important;
  }

  .mobile-btn-submit {
    width: 80% !important;
    margin: 0 auto !important;
    display: block !important;
    padding: 9px 12px !important;
    font-size: 0.85rem !important;
    border-radius: 8px !important;
    text-align: center !important;
  }

  .mobile-submit-container {
    text-align: center !important;
  }
}
