/* DeskKeep App Styles - matching landing page design tokens */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sage: #4A7C6F;
  --sage-light: #6B9E8F;
  --sage-dark: #3A6359;
  --cream: #FDF8F0;
  --warm-white: #FEFCF9;
  --navy: #1A2332;
  --navy-light: #2D3A4A;
  --sand: #E8DFD0;
  --sand-light: #F2ECE3;
  --accent: #D4956A;
  --accent-light: #E8B892;
  --danger: #C62828;
  --danger-light: #FFEBEE;
  --success: #2E7D32;
  --success-light: #E8F5E9;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

/* ---- AUTH PAGES ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(26,35,50,0.08);
  border: 1px solid var(--sand);
}

.auth-card .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--sage-dark);
  text-align: center;
  margin-bottom: 8px;
}

.auth-card .logo span { color: var(--accent); }

.auth-card h2 {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 32px;
  color: var(--navy);
}

.auth-card .subtitle {
  text-align: center;
  color: var(--navy-light);
  font-size: 0.9rem;
  margin-top: -24px;
  margin-bottom: 32px;
}

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--navy-light);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--sand);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--navy);
  background: var(--warm-white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(74,124,111,0.1);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--sage);
  color: white;
}
.btn-primary:hover { background: var(--sage-dark); }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: #C4855A; }

.btn-outline {
  background: transparent;
  color: var(--sage);
  border: 1.5px solid var(--sage);
}
.btn-outline:hover { background: rgba(74,124,111,0.06); }

.btn-ghost {
  background: transparent;
  color: var(--navy-light);
  padding: 8px 16px;
}
.btn-ghost:hover { background: var(--sand-light); }

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

.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: 8px; }

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- APP LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: white;
  border-right: 1px solid var(--sand);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--sage-dark);
  padding: 0 24px;
  margin-bottom: 32px;
  cursor: pointer;
}

.sidebar .logo span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--navy-light);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}

.nav-link:hover { background: var(--sand-light); color: var(--navy); }

.nav-link.active {
  background: rgba(74,124,111,0.08);
  color: var(--sage-dark);
  font-weight: 600;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--sand-light);
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--sage);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  font-family: 'Space Grotesk', sans-serif;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--navy);
}

.user-email {
  font-size: 0.75rem;
  color: var(--navy-light);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px;
  max-width: 1200px;
}

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

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--navy-light);
  margin-top: 4px;
}

/* ---- STAT CARDS ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--sand);
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--navy-light);
  font-family: 'Space Grotesk', sans-serif;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -1px;
}

.stat-card.sage .stat-value { color: var(--sage); }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }

/* ---- CARDS / PANELS ---- */
.card {
  background: white;
  border-radius: 16px;
  padding: 28px;
  border: 1px solid var(--sand);
  margin-bottom: 24px;
}

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

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ---- CATEGORY BARS ---- */
.category-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.category-bar .bar-fill {
  flex: 1;
  height: 8px;
  background: var(--sand-light);
  border-radius: 4px;
  overflow: hidden;
}

.category-bar .bar-fill-inner {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.category-bar .cat-name {
  font-size: 0.85rem;
  color: var(--navy-light);
  min-width: 130px;
}

.category-bar .cat-amount {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  min-width: 80px;
  text-align: right;
  font-family: 'Space Grotesk', sans-serif;
}

/* ---- TABLE ---- */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--navy-light);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  border-bottom: 2px solid var(--sand-light);
}

table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--sand-light);
  color: var(--navy);
}

table tr:hover td { background: rgba(253,248,240,0.5); }

table .amount {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

/* ---- STATUS BADGES ---- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-draft { background: var(--sand-light); color: var(--navy-light); }
.badge-sent { background: rgba(74,124,111,0.1); color: var(--sage-dark); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-overdue { background: var(--danger-light); color: var(--danger); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,35,50,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: white;
  border-radius: 20px;
  padding: 36px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(26,35,50,0.15);
}

.modal-wide { max-width: 720px; }

.modal h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

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

/* ---- INVOICE ITEMS ---- */
.line-items-table {
  width: 100%;
  margin-bottom: 16px;
}

.line-items-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy-light);
  padding: 8px 0;
  border-bottom: 2px solid var(--sand-light);
  text-align: left;
}

.line-items-table td {
  padding: 8px 4px;
  vertical-align: top;
}

.line-items-table input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--sand);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  background: var(--warm-white);
  outline: none;
}

.line-items-table input:focus {
  border-color: var(--sage);
}

.remove-item-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  font-size: 1.1rem;
}

.remove-item-btn:hover { background: var(--danger-light); }

.invoice-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding: 16px 0;
  border-top: 2px solid var(--sand-light);
}

.invoice-total-row {
  display: flex;
  gap: 24px;
  font-size: 0.9rem;
}

.invoice-total-row .label { color: var(--navy-light); min-width: 100px; text-align: right; }
.invoice-total-row .value { font-family: 'Space Grotesk', sans-serif; font-weight: 600; min-width: 100px; text-align: right; }

.invoice-total-row.grand {
  font-size: 1.1rem;
  padding-top: 8px;
  border-top: 2px solid var(--sage);
}
.invoice-total-row.grand .value { color: var(--sage); font-size: 1.2rem; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--navy-light);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--navy);
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 24px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 8px 30px rgba(26,35,50,0.12);
  border-left: 4px solid var(--sage);
  font-size: 0.9rem;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--navy-light);
  gap: 12px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--sand);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .mobile-menu-btn { display: block !important; }
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 150;
  background: white;
  border: 1px solid var(--sand);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--navy);
  stroke-width: 2;
  fill: none;
}

/* Invoice detail view */
.invoice-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.invoice-party-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sage);
  font-weight: 600;
  margin-bottom: 8px;
}

.invoice-party-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.invoice-party-detail {
  font-size: 0.85rem;
  color: var(--navy-light);
  line-height: 1.5;
}

.actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Clickable table rows */
table tr.clickable { cursor: pointer; }
table tr.clickable:hover td { background: rgba(74,124,111,0.03); }
