/* ============================================================
   Apogee Expenses — Web Interface
   Design system based on apogeecorp.com
   ============================================================ */

:root {
  --navy:       #002D5B;
  --blue:       #009ADE;
  --blue-dark:  #0081bb;
  --green:      #1A6B3C;
  --green-dark: #145730;
  --text:       #626262;
  --heading:    #161922;
  --subtle:     #8a8a8a;
  --border:     #e2e8f0;
  --bg:         #f7f9fc;
  --bg-alt:     #f2f2f2;
  --bg-blue:    #ebf2f9;
  --white:      #ffffff;
  --danger:     #d93025;
  --success:    #1a6b3c;
  --sidebar-w:  260px;
  --radius:     12px;
  --radius-btn: 50px;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ── LOGIN ───────────────────────────────────────────────── */
#screen-login {
  background: linear-gradient(135deg, var(--navy) 0%, #004a8f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo svg { width: 200px; height: 40px; }

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.login-card h2 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 4px;
}

.login-sub {
  color: var(--subtle);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ── APP SHELL ───────────────────────────────────────────── */
#screen-app {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 400;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.08);
}

.nav-item.active {
  color: #ffffff;
  background: rgba(0,154,222,0.18);
  border-left-color: var(--blue);
  font-weight: 500;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#sidebar-user-name {
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── MOBILE TOPBAR ───────────────────────────────────────── */
#mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 150;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.mobile-logo { width: 120px; height: 24px; }

#hamburger {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--heading);
  cursor: pointer;
  padding: 4px 8px;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 190;
}

/* ── MAIN CONTENT ────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 0;
}

/* ── PAGE ────────────────────────────────────────────────── */
.page {
  padding: 40px 48px;
  max-width: 1100px;
}

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

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--heading);
}

.page-header-actions { display: flex; gap: 12px; }

/* ── SUMMARY CARDS ───────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 36px;
}

.summary-card {
  border-radius: var(--radius);
  padding: 28px 32px;
  color: var(--white);
  position: relative;
  overflow: hidden;
}

.summary-card::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.card-company { background: linear-gradient(135deg, var(--navy) 0%, #004a8f 100%); }
.card-own     { background: linear-gradient(135deg, var(--green) 0%, #2a9d5c 100%); }

.summary-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  margin-bottom: 4px;
}

.summary-period {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 12px;
}

.summary-amount {
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.summary-sub {
  font-size: 0.82rem;
  opacity: 0.7;
}

/* ── SECTION TITLE ───────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 16px;
}

.section-title-sm {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--heading);
  margin: 16px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── EXPENSE LIST ────────────────────────────────────────── */
.expense-list {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.expense-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto 80px;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}

.expense-row:last-child { border-bottom: none; }
.expense-row:hover { background: var(--bg); }

.expense-card-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: auto;
}

.dot-company { background: var(--navy); }
.dot-own     { background: var(--green); }

.expense-main { min-width: 0; }

.expense-establishment {
  font-weight: 500;
  color: var(--heading);
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-meta {
  font-size: 0.78rem;
  color: var(--subtle);
}

.expense-type-badge {
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg-blue);
  color: var(--blue-dark);
  padding: 3px 10px;
  border-radius: 50px;
  white-space: nowrap;
  flex-shrink: 0;
}

.expense-amount {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.95rem;
  text-align: right;
  white-space: nowrap;
}

.expense-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--subtle);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: all 0.12s;
  line-height: 1;
}

.btn-icon:hover { background: var(--bg-alt); color: var(--heading); }
.btn-icon.delete:hover { background: #fef2f2; color: var(--danger); }

.loading-row, .empty-row {
  padding: 32px;
  text-align: center;
  color: var(--subtle);
  font-size: 0.9rem;
}

.view-all-wrap { text-align: center; margin-bottom: 8px; }

/* ── FILTERS BAR ─────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

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

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── FORM CARD ───────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 36px 40px;
  box-shadow: var(--shadow);
  max-width: 720px;
}

.form-row { display: flex; gap: 20px; }
.form-row.two-col > * { flex: 1; }
.form-row.three-col > * { flex: 1; }

/* ── FIELDS ──────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--heading);
}

.req { color: var(--blue); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  color: var(--heading);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,154,222,0.12);
}

input[readonly] {
  background: var(--bg);
  color: var(--subtle);
}

input:disabled { background: var(--bg); color: var(--subtle); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23626262' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea { resize: vertical; min-height: 80px; }

.input-prefix {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-prefix:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,154,222,0.12);
}

.input-prefix span {
  padding: 10px 12px;
  background: var(--bg);
  color: var(--subtle);
  font-size: 0.9rem;
  font-weight: 500;
  border-right: 1.5px solid var(--border);
  flex-shrink: 0;
}

.input-prefix input {
  border: none;
  border-radius: 0;
  flex: 1;
  box-shadow: none !important;
}

.radio-group {
  display: flex;
  gap: 20px;
  padding: 10px 0;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 400 !important;
}

.radio-label input[type="radio"] {
  width: auto;
  accent-color: var(--blue);
}

/* ── RECEIPT UPLOAD ──────────────────────────────────────── */
.receipt-upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
  position: relative;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.receipt-upload-area:hover {
  border-color: var(--blue);
  background: var(--bg-blue);
}

.upload-icon { font-size: 2rem; margin-bottom: 8px; color: var(--blue); }

.receipt-upload-area div:not(.upload-icon) {
  font-size: 0.88rem;
  color: var(--subtle);
}

.upload-hint { font-size: 0.75rem !important; margin-top: 4px; }

#receipt-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#receipt-preview {
  max-height: 200px;
  max-width: 100%;
  border-radius: 8px;
  object-fit: contain;
}

/* ── FORM ACTIONS ────────────────────────────────────────── */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: var(--radius-btn);
  border: none;
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 4px 14px rgba(0,154,222,0.3); }
.btn-primary:active { transform: translateY(1px); }

.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--blue);
}

.btn-outline:hover { background: var(--bg-blue); }

.btn-success {
  background: var(--green);
  color: var(--white);
}

.btn-success:hover { background: var(--green-dark); box-shadow: 0 4px 14px rgba(26,107,60,0.3); }

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

.btn-danger:hover { background: #b5261d; }

.btn-full { width: 100%; }

.btn-sm { padding: 6px 16px; font-size: 0.8rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover { color: var(--blue-dark); }

/* ── REPORTS PAGE ────────────────────────────────────────── */
.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.report-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
}

.report-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.report-card-icon {
  font-size: 1.8rem;
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.company-icon { background: var(--bg-blue); }
.own-icon     { background: #e8f5ee; }

.report-card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 4px;
}

.report-card-header p {
  font-size: 0.82rem;
  color: var(--subtle);
}

.own-card-unsubmitted {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.info-box {
  font-size: 0.88rem;
  color: var(--text);
}

.batches-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.batch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px 16px;
  gap: 12px;
}

.batch-info { flex: 1; min-width: 0; }
.batch-ref  { font-size: 0.82rem; font-weight: 500; color: var(--heading); }
.batch-meta { font-size: 0.75rem; color: var(--subtle); }
.batch-amount { font-weight: 600; color: var(--heading); font-size: 0.92rem; }

/* ── SETTINGS PAGE ───────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.settings-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-card.full-width { grid-column: 1 / -1; }

.types-list {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.type-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  gap: 10px;
}

.type-name {
  font-size: 0.88rem;
  color: var(--heading);
  flex: 1;
}

.type-name.inactive { text-decoration: line-through; color: var(--subtle); }

.add-type-form {
  display: flex;
  gap: 10px;
}

.add-type-form input { flex: 1; }

/* ── FORM MESSAGES ───────────────────────────────────────── */
.form-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.form-success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 10px;
}

.modal p {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--heading);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 600;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.2s ease;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--danger); }

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

/* ── SUBMITTED BADGE ─────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-submitted { background: #f0fdf4; color: var(--success); }
.badge-pending   { background: #fffbeb; color: #92400e; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  #sidebar-overlay.open { display: block; }

  #mobile-topbar { display: flex; }

  #main-content {
    margin-left: 0;
    padding-top: 56px;
  }

  .page { padding: 24px 20px; }

  .summary-grid { grid-template-columns: 1fr; }

  .reports-grid { grid-template-columns: 1fr; }

  .settings-grid { grid-template-columns: 1fr; }

  .settings-card.full-width { grid-column: auto; }

  .form-card { padding: 24px 20px; }

  .form-row.two-col,
  .form-row.three-col { flex-direction: column; gap: 0; }

  .expense-row {
    grid-template-columns: 10px 1fr auto;
    grid-template-rows: auto auto;
  }

  .expense-card-dot { grid-row: 1 / 3; }
  .expense-type-badge { display: none; }
  .expense-actions { grid-column: 3; grid-row: 1 / 3; }
}

@media (max-width: 500px) {
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .login-card { padding: 28px 20px; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-group { width: 100%; }
  .filter-group select { width: 100%; }
}
