/* ==========================================================================
   BẢNG THU CHI MIDON - Modern Design System & Spreadsheet Stylesheet
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --grid-border: #cbd5e1;
  --header-bg: #f1f5f9;
  
  --cell-selected-bg: rgba(37, 99, 235, 0.12);
  --cell-selected-border: #2563eb;
  --range-selected-bg: rgba(79, 70, 229, 0.1);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(37, 99, 235, 0.18);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-main: #0b1120;
  --bg-surface: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.88);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.2);
  --accent: #6366f1;
  --accent-hover: #818cf8;
  
  --border: #334155;
  --border-dark: #475569;
  --grid-border: #334155;
  --header-bg: #1e293b;
  
  --cell-selected-bg: rgba(59, 130, 246, 0.25);
  --cell-selected-border: #60a5fa;
  --range-selected-bg: rgba(99, 102, 241, 0.2);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
}

/* Layout Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Topbar Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 2rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar .logo-icon {
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.2));
}

.topbar .brand-text h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar .brand-text h1 span {
  color: var(--primary);
}

.topbar .brand-text .subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Main Nav */
.main-nav {
  display: flex;
  gap: 6px;
  background: var(--bg-main);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.nav-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.nav-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  background: var(--bg-main);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
  border-color: var(--primary);
}

/* Buttons */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #ffffff;
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--header-bg);
  border-color: var(--primary);
}

.btn-block {
  width: 100%;
}

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

/* Glass Panel Card */
.glass-panel {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Login Screen */
.login-box {
  max-width: 460px;
  margin: 3.5rem auto;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.login-header .login-badge {
  font-size: 2.8rem;
  margin-bottom: 0.75rem;
}

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}

.login-form .input-wrapper input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: var(--bg-main);
  color: var(--text-main);
  margin-bottom: 1.25rem;
  outline: none;
  transition: all 0.2s ease;
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.login-msg {
  margin-top: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* System Lockdown Screen */
.midon-lockdown {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 6, 23, 0.94);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lockdown-card {
  max-width: 600px;
  text-align: center;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 50px rgba(239, 68, 68, 0.3);
}

.lockdown-badge {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  animation: pulse 1s infinite alternate;
}

.lockdown-title {
  color: #ef4444;
  font-size: 1.4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 1rem;
}

.lockdown-desc {
  color: #fca5a5;
  font-size: 1rem;
  line-height: 1.6;
}

@keyframes pulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.95); opacity: 0.7; }
}

.blink {
  animation: blinkAnim 1s infinite alternate;
}

@keyframes blinkAnim {
  from { opacity: 1; }
  to { opacity: 0.5; }
}

/* Dashboard Header */
.dashboard-header {
  margin-bottom: 1.25rem;
}

.dashboard-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

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

/* Cloud Sync Panel */
.data-import-panel .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.data-import-panel h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.badge-info {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.cloud-sync-row {
  display: flex;
  gap: 10px;
  margin-bottom: 0.75rem;
}

.cloud-sync-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  color: var(--text-main);
  outline: none;
  font-size: 0.9rem;
}

.cloud-sync-row input:focus {
  border-color: var(--primary);
}

.data-payload-toggle summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.data-import-panel .fake-textarea, #dataPayloadInput {
  box-sizing: border-box !important;
  display: block !important;
  width: 100% !important;
  min-height: 140px !important;
  max-height: 260px;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
  outline: none;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.fake-textarea:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

#dataPayloadInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

/* Spreadsheet Toolbar */
.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 4px;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
}

.btn-tool {
  padding: 7px 12px;
  border: 1px solid var(--border-dark);
  background: var(--bg-main);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-tool:hover {
  background: var(--header-bg);
  border-color: var(--primary);
}

.btn-danger-soft {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

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

.btn-primary-soft {
  background: var(--primary-light);
  color: var(--primary);
  border-color: transparent;
}

.formula-group {
  flex: 1;
  min-width: 320px;
}

.formula-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0 8px;
}

.formula-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.formula-input-wrap .fx-icon {
  font-weight: 800;
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 8px;
}

.formula-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
}

.color-picker-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  background: var(--bg-main);
}

.color-picker-label input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.color-indicator {
  font-weight: 800;
  font-size: 0.9rem;
}

/* SPREADSHEET GRID CONTAINER & TABLE */
.sheet-container {
  overflow: auto;
  max-height: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  position: relative;
}

table.sheet, table.sheet-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  font-size: 0.88rem;
  user-select: none;
}

table.sheet th, table.sheet td {
  border: 1px solid var(--grid-border);
  height: 34px;
  padding: 0 8px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header Row (A, B, C...) & Row STT */
table.sheet th {
  background: var(--header-bg);
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

table.sheet th.row-header, table.sheet td.stt-cell {
  position: sticky;
  left: 0;
  z-index: 11;
  background: var(--header-bg);
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
  width: 48px;
  min-width: 48px;
}

table.sheet th.row-header {
  z-index: 20;
}

/* Data Cells */
table.sheet td[data-cell], table.sheet td.cell {
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  cursor: cell;
  transition: background-color 0.1s ease;
}

/* Cell States & Formatting */
table.sheet td.cell-selected, table.sheet td.selected {
  background-color: var(--cell-selected-bg) !important;
  box-shadow: inset 0 0 0 2px var(--cell-selected-border) !important;
  z-index: 5;
}

table.sheet td.range-selected {
  background-color: var(--range-selected-bg) !important;
}

table.sheet td.fill-target {
  outline: 2px dashed var(--accent) !important;
}

table.sheet td.bold-text, table.sheet td.bold {
  font-weight: 700;
}

table.sheet td.thick-border {
  border: 2px solid var(--text-main) !important;
}

/* Fill Handle Dot */
#fillHandle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border: 1px solid #ffffff;
  cursor: crosshair;
  z-index: 30;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

/* Cell Status Bar Footer */
.sheet-status-bar {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.highlight-badge {
  font-weight: 700;
  color: var(--primary);
}

/* Account Management Page */
.account-card {
  max-width: 680px;
  margin: 0 auto;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input {
  padding: 10px 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.account-status {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Modern Aesthetic Enhancements */
.gradient-text {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.18));
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  flex-shrink: 0;
}

.login-badge-glow {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.3));
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.btn-discord {
  background: linear-gradient(135deg, #5865F2, #4752C4) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(88, 101, 242, 0.35) !important;
}

.btn-discord:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.5) !important;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-icon {
  font-size: 1.4rem;
}

.info-card-gradient {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(59, 130, 246, 0.06)) !important;
  border: 1px solid rgba(16, 185, 129, 0.2) !important;
  padding: 1.25rem !important;
  border-radius: var(--radius-md) !important;
}

.code-badge {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #38bdf8;
  word-break: break-all;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px dashed rgba(56, 189, 248, 0.3);
  margin-top: 0.4rem;
}
