*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563EB;
  --blue-dark: #1D4ED8;
  --blue-light: #EFF6FF;
  --green: #16A34A;
  --green-light: #F0FDF4;
  --red: #DC2626;
  --red-light: #FEF2F2;
  --amber: #D97706;
  --amber-light: #FFFBEB;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --sidebar-w: 230px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* SCREENS */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* LICENSE SCREEN */
.license-wrapper {
  width: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1D4ED8 50%, #2563EB 100%);
  padding: 24px;
}

.license-card {
  background: white; border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.brand-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.brand-logo span {
  font-size: 22px; font-weight: 700; color: var(--gray-900);
}

.license-card h1 {
  font-size: 20px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px;
}
.subtitle { color: var(--gray-500); margin-bottom: 28px; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--gray-600); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 14px; color: var(--gray-800);
  transition: border-color .2s, box-shadow .2s; outline: none;
  background: white;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; font-family: inherit; }

.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }

.btn-icon {
  padding: 10px; border: 1.5px solid var(--gray-200); border-radius: 8px;
  background: white; cursor: pointer; color: var(--gray-500); display: flex;
  align-items: center; justify-content: center; transition: all .2s;
}
.btn-icon:hover { border-color: var(--blue); color: var(--blue); }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 11px 20px; background: var(--blue); color: white;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .2s, transform .1s;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.btn-expense { background: var(--red); }
.btn-primary.btn-expense:hover { background: #B91C1C; }

.btn-outline {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; background: white; color: var(--gray-600);
  border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: 14px;
  font-weight: 500; cursor: pointer; transition: all .2s;
}
.btn-outline:hover { border-color: var(--gray-400); background: var(--gray-50); }

.btn-danger {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; background: var(--red); color: white;
  border: none; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background .2s;
}
.btn-danger:hover { background: #B91C1C; }

.error-msg {
  background: var(--red-light); color: var(--red); padding: 10px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 12px;
  border: 1px solid #FECACA;
}

.license-info {
  display: flex; align-items: center; gap: 6px; margin-top: 20px;
  font-size: 12px; color: var(--gray-400); justify-content: center;
}

.powered-by {
  text-align: center; margin-top: 12px; font-size: 11px; color: var(--gray-400);
}

/* APP LAYOUT */
#appScreen { flex-direction: row; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--gray-900);
  display: flex; flex-direction: column; flex-shrink: 0;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-name { display: block; font-size: 15px; font-weight: 700; color: white; }
.brand-sub { display: block; font-size: 11px; color: var(--gray-400); }

.company-badge {
  display: flex; align-items: center; gap: 6px;
  margin: 12px 12px 4px; padding: 8px 12px;
  background: rgba(255,255,255,.06); border-radius: 8px;
  font-size: 12px; color: var(--gray-400);
}
.company-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--gray-400);
  font-size: 13px; font-weight: 500; transition: all .15s;
  text-decoration: none; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: var(--gray-200); text-decoration: none; }
.nav-item.active { background: var(--blue); color: white; }

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; flex-direction: column; gap: 10px;
}
.sidebar-footer a { font-size: 11px; color: var(--gray-500); }
.sidebar-footer a:hover { color: var(--gray-300); }

.btn-logout {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; background: transparent; border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px; color: var(--gray-400); font-size: 12px; cursor: pointer;
  transition: all .2s; width: fit-content;
}
.btn-logout:hover { border-color: var(--red); color: #F87171; }

/* MAIN CONTENT */
.main-content {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: white; border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 17px; font-weight: 700; color: var(--gray-900); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.top-company { font-size: 12px; color: var(--gray-500); font-weight: 500; }
.date-badge {
  font-size: 12px; color: var(--gray-500); background: var(--gray-100);
  padding: 4px 10px; border-radius: 20px;
}

/* PAGES */
.page { display: none; padding: 24px 28px; flex: 1; }
.page.active { display: block; }

/* STATS */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: white; border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card.income .stat-icon { background: var(--green-light); color: var(--green); }
.stat-card.expense .stat-icon { background: var(--red-light); color: var(--red); }
.stat-card.balance .stat-icon { background: var(--blue-light); color: var(--blue); }
.stat-card.count .stat-icon { background: var(--amber-light); color: var(--amber); }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; margin-bottom: 3px; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--gray-900); }

/* SECTION ROW */
.section-row { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.section-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.section-header h3 { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.badge-count {
  background: var(--gray-100); color: var(--gray-600);
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}

.transaction-list { padding: 8px 0; max-height: 320px; overflow-y: auto; }
.transaction-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; transition: background .15s;
}
.transaction-item:hover { background: var(--gray-50); }
.tx-left { display: flex; align-items: center; gap: 12px; }
.tx-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.tx-dot.income { background: var(--green); }
.tx-dot.expense { background: var(--red); }
.tx-desc { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.tx-date { font-size: 11px; color: var(--gray-400); margin-top: 1px; }
.tx-amount { font-size: 13px; font-weight: 700; }
.tx-amount.income { color: var(--green); }
.tx-amount.expense { color: var(--red); }

.category-list { padding: 12px 20px; }
.cat-item { margin-bottom: 12px; }
.cat-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--gray-600); margin-bottom: 5px;
}
.cat-bar { height: 6px; background: var(--gray-100); border-radius: 10px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 10px; transition: width .5s; }

/* EMPTY STATE */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 20px; color: var(--gray-300); gap: 10px;
}
.empty-state p { font-size: 13px; color: var(--gray-400); }

/* PAGE ACTIONS */
.page-actions {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.page-actions .btn-primary { width: auto; }

.filter-bar { display: flex; gap: 8px; margin-left: auto; }
.filter-bar select, .filter-bar input {
  padding: 9px 12px; border: 1.5px solid var(--gray-200); border-radius: 8px;
  font-size: 13px; color: var(--gray-700); outline: none; background: white;
  transition: border-color .2s;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--blue); }

/* TABLE */
.table-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--gray-50); }
.data-table th {
  padding: 12px 16px; text-align: left; font-size: 11px; font-weight: 700;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--gray-100);
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--gray-50);
  font-size: 13px; color: var(--gray-700);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }

.amount-income { color: var(--green); font-weight: 700; }
.amount-expense { color: var(--red); font-weight: 700; }

.action-btns { display: flex; gap: 6px; }
.btn-sm {
  padding: 5px 8px; border-radius: 6px; font-size: 12px; cursor: pointer;
  border: none; display: flex; align-items: center; gap: 4px; transition: all .15s;
}
.btn-sm.edit { background: var(--blue-light); color: var(--blue); }
.btn-sm.edit:hover { background: #DBEAFE; }
.btn-sm.delete { background: var(--red-light); color: var(--red); }
.btn-sm.delete:hover { background: #FEE2E2; }
.cat-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; background: var(--gray-100); color: var(--gray-600);
}

/* REPORTS */
.reports-filters {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
  background: white; padding: 16px 20px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.form-group-inline { display: flex; align-items: center; gap: 8px; }
.form-group-inline label { font-size: 12px; font-weight: 600; color: var(--gray-500); white-space: nowrap; }
.form-group-inline input {
  padding: 9px 12px; border: 1.5px solid var(--gray-200); border-radius: 8px;
  font-size: 13px; outline: none; transition: border-color .2s;
}
.form-group-inline input:focus { border-color: var(--blue); }
.reports-filters .btn-primary, .reports-filters .btn-outline { width: auto; }

.report-content { background: white; border-radius: var(--radius); box-shadow: var(--shadow); min-height: 300px; }
.report-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--gray-100);
}
.report-stat {
  background: white; padding: 24px 28px; text-align: center;
}
.report-stat .label { font-size: 12px; color: var(--gray-500); margin-bottom: 6px; }
.report-stat .value { font-size: 22px; font-weight: 700; }
.report-stat .value.pos { color: var(--green); }
.report-stat .value.neg { color: var(--red); }
.report-stat .value.neutral { color: var(--blue); }
.report-table-wrap { overflow-x: auto; }

/* SETTINGS */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.settings-card h3 { font-size: 15px; font-weight: 700; color: var(--gray-800); margin-bottom: 16px; }
.settings-card .btn-primary { width: auto; margin-top: 8px; }
.settings-card.danger-zone { border: 1.5px solid #FECACA; }
.settings-card.danger-zone p { font-size: 13px; color: var(--gray-500); margin-bottom: 14px; }

.category-manager { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.cat-tag {
  display: flex; align-items: center; gap: 6px;
  background: var(--gray-100); padding: 5px 10px; border-radius: 20px;
  font-size: 12px; color: var(--gray-700);
}
.cat-tag button {
  background: none; border: none; cursor: pointer; color: var(--gray-400);
  padding: 0; display: flex; align-items: center; transition: color .15s;
}
.cat-tag button:hover { color: var(--red); }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 100; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: white; border-radius: 14px; width: 90%; max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer; color: var(--gray-400);
  padding: 4px; border-radius: 6px; display: flex; align-items: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-footer .btn-primary { width: auto; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* DOMAIN INPUT */
.domain-input-wrap {
  position: relative; display: flex; align-items: center; width: 100%;
}
.domain-prefix {
  position: absolute; left: 11px; font-size: 15px; pointer-events: none;
  line-height: 1;
}
.domain-input-wrap input {
  padding-left: 34px !important;
  font-family: 'Courier New', monospace; font-size: 14px !important;
  letter-spacing: .3px;
}
.domain-hint {
  font-size: 11px; color: var(--gray-400); margin-top: 5px;
}

/* LICENSE LOADING STATE */
.btn-primary:disabled {
  opacity: .65; cursor: not-allowed; pointer-events: none;
}
.license-card .btn-primary {
  position: relative; overflow: hidden;
}
.license-card .btn-primary:disabled::after {
  content: '';
  position: absolute; left: -60%; top: 0; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  animation: shimmer 1s infinite;
}
@keyframes shimmer {
  to { left: 120%; }
}

/* BLOCKER SCREEN */
#blockerScreen a { color: #93C5FD; }
#blockerScreen a:hover { color: white; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
