/* UpLink Portal — Clean Professional Spreadsheet UI */
:root {
  --blue: #1a73e8;
  --blue-light: #e8f0fe;
  --blue-dark: #174ea6;
  --green: #34a853;
  --green-bg: #e6f4ea;
  --yellow: #f9ab00;
  --yellow-bg: #fef7e0;
  --red: #ea4335;
  --red-bg: #fce8e6;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-300: #dadce0;
  --gray-400: #bdc1c6;
  --gray-500: #9aa0a6;
  --gray-600: #80868b;
  --gray-700: #5f6368;
  --gray-800: #3c4043;
  --gray-900: #202124;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: #fff; color: var(--gray-900); font-size: 13px; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--gray-50);
}
.login-box {
  background: #fff; border-radius: 12px; padding: 48px 40px; width: 380px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08); text-align: center;
}
.login-box h1 { font-size: 24px; margin-bottom: 6px; color: var(--gray-900); }
.login-box .subtitle { color: var(--gray-600); margin-bottom: 32px; font-size: 14px; }
.login-box input {
  display: block; width: 100%; padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px;
  outline: none; transition: border-color 0.15s;
}
.login-box input:focus { border-color: var(--blue); }
.login-box button {
  width: 100%; padding: 12px; background: var(--blue); color: #fff; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.login-box button:hover { background: var(--blue-dark); }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; display: none; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px; border-bottom: 1px solid var(--gray-200);
  background: #fff; position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h1 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.header-left .logo { color: var(--blue); font-weight: 800; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-right .user-info { font-size: 13px; color: var(--gray-700); }
.header-right .role-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
  background: var(--blue-light); color: var(--blue);
}
.btn-logout {
  padding: 6px 14px; border: 1px solid var(--gray-300); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 12px; color: var(--gray-700);
}
.btn-logout:hover { background: var(--gray-50); }

/* Tabs */
.tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--gray-200);
  padding: 0 20px; background: #fff;
}
.tab {
  padding: 10px 20px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--gray-600); border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--gray-900); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Content */
.content { padding: 0; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Dashboard */
.dashboard { padding: 24px 20px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: 10px;
  padding: 20px; display: flex; flex-direction: column;
}
.stat-card .stat-label { font-size: 12px; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-card .stat-sub { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.stat-card.green { border-left: 4px solid var(--green); }
.stat-card.yellow { border-left: 4px solid var(--yellow); }
.stat-card.red { border-left: 4px solid var(--red); }
.stat-card.blue { border-left: 4px solid var(--blue); }

.breakdown-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.breakdown-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; padding: 20px;
}
.breakdown-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--gray-800); }
.breakdown-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--gray-100); }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { color: var(--gray-700); }
.breakdown-value { font-weight: 600; font-family: var(--mono); }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  border-bottom: 1px solid var(--gray-200); background: var(--gray-50);
  flex-wrap: wrap;
}
.toolbar input[type="text"] {
  padding: 7px 12px; border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 13px; width: 260px; outline: none;
}
.toolbar input[type="text"]:focus { border-color: var(--blue); }
.toolbar select {
  padding: 7px 10px; border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 13px; background: #fff; outline: none; cursor: pointer;
}
.filter-btn {
  padding: 7px 14px; border: 1px solid var(--gray-300); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 12px; font-weight: 500;
  transition: all 0.15s;
}
.filter-btn:hover { background: var(--gray-100); }
.filter-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.toolbar .count { font-size: 12px; color: var(--gray-500); margin-left: auto; }

/* Spreadsheet Grid */
.grid-container { overflow-x: auto; }
.grid-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.grid-table thead { position: sticky; top: 52px; z-index: 50; }
.grid-table th {
  background: var(--gray-100); padding: 8px 10px; text-align: left;
  border-bottom: 2px solid var(--gray-300); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.3px; color: var(--gray-700);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.grid-table th:hover { background: var(--gray-200); }
.grid-table th .sort-arrow { margin-left: 4px; font-size: 10px; opacity: 0.4; }
.grid-table th.sorted .sort-arrow { opacity: 1; color: var(--blue); }
.grid-table td {
  padding: 6px 10px; border-bottom: 1px solid var(--gray-100);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}
.grid-table tr { transition: background 0.1s; }
.grid-table tr:hover { background: var(--blue-light); }
.grid-table tr.row-green { background: var(--green-bg); }
.grid-table tr.row-green:hover { background: #d0ecd6; }
.grid-table tr.row-yellow { background: var(--yellow-bg); }
.grid-table tr.row-yellow:hover { background: #faefc8; }
.grid-table tr.row-red { background: var(--red-bg); }
.grid-table tr.row-red:hover { background: #f5d0cc; }
.grid-table tr { cursor: pointer; }

.type-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.type-expense { background: #fce4ec; color: #c62828; }
.type-bill { background: #e8eaf6; color: #283593; }
.type-invoice { background: #e0f2f1; color: #00695c; }
.type-journal { background: #f3e5f5; color: #6a1b9a; }

.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 600;
}
.status-paid, .status-published { background: var(--green-bg); color: var(--green); }
.status-unpaid, .status-open, .status-draft { background: var(--yellow-bg); color: #e37400; }
.status-overdue { background: var(--red-bg); color: var(--red); }
.status-unknown { background: var(--gray-100); color: var(--gray-600); }

.receipt-icon { font-size: 14px; }
.receipt-yes { color: var(--green); }
.receipt-no { color: var(--red); }

.amount-cell { text-align: right; font-family: var(--mono); font-weight: 500; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 20px; border-top: 1px solid var(--gray-200);
}
.pagination button {
  padding: 6px 12px; border: 1px solid var(--gray-300); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 12px;
}
.pagination button:hover { background: var(--gray-50); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .page-info { font-size: 12px; color: var(--gray-600); }

/* Action Items */
.action-items { padding: 20px; }
.action-items h2 { font-size: 18px; margin-bottom: 16px; }
.action-list { display: flex; flex-direction: column; gap: 10px; }
.action-card {
  border: 1px solid var(--gray-200); border-radius: 10px; padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 14px; transition: box-shadow 0.15s;
}
.action-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.action-priority {
  width: 8px; min-height: 40px; border-radius: 4px; flex-shrink: 0;
}
.priority-1 { background: var(--red); }
.priority-2 { background: var(--yellow); }
.priority-3 { background: var(--blue); }
.action-body { flex: 1; }
.action-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.action-desc { font-size: 13px; color: var(--gray-700); line-height: 1.5; }
.action-meta {
  display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--gray-500);
}
.action-meta span { display: flex; align-items: center; gap: 4px; }
.action-status-select {
  padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 11px; background: #fff; cursor: pointer;
}

/* Transaction Detail Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 600px; max-width: 90vw;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--gray-600); padding: 4px; line-height: 1;
}
.modal-body { padding: 20px 24px; }
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.detail-label { width: 140px; font-weight: 600; color: var(--gray-700); font-size: 12px; }
.detail-value { flex: 1; font-size: 13px; }
.upload-area {
  margin-top: 16px; padding: 20px; border: 2px dashed var(--gray-300);
  border-radius: 8px; text-align: center; cursor: pointer;
  transition: border-color 0.15s;
}
.upload-area:hover { border-color: var(--blue); }
.upload-area input { display: none; }
.upload-area p { color: var(--gray-600); font-size: 13px; }
.receipt-list { margin-top: 12px; }
.receipt-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  font-size: 13px; color: var(--blue);
}
.receipt-item a { color: var(--blue); text-decoration: none; }
.receipt-item a:hover { text-decoration: underline; }

/* Loading spinner */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--gray-300); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .breakdown-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type="text"] { width: 100%; }
}