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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222535;
  --border: #2d3148;
  --text: #e8eaf0;
  --text-muted: #7b82a0;
  --accent: #4f6ef7;
  --accent-hover: #3d5be0;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --paid-bg: rgba(34,197,94,0.12);
  --active-bg: rgba(79,110,247,0.12);
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }

/* Login */
.screen { min-height: 100vh; }
.login-box {
  max-width: 380px; margin: 0 auto; padding: 60px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 32px;
}
.logo { text-align: center; }
.logo-icon { font-size: 40px; margin-bottom: 12px; }
.logo h1 { font-size: 24px; font-weight: 700; }
.logo p { color: var(--text-muted); margin-top: 4px; font-size: 13px; }

#login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }

/* Sidebar layout */
#app-screen { display: flex !important; min-height: 100vh; }
.sidebar {
  width: 220px; min-height: 100vh; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 10;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon { font-size: 22px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; color: var(--text-muted); text-decoration: none;
  font-size: 13.5px; font-weight: 500; transition: all 0.15s; cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: rgba(79,110,247,0.1); border-left-color: var(--accent); }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.btn-logout {
  display: flex; align-items: center; gap: 8px; background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 13px; width: 100%;
  padding: 8px 4px; transition: color 0.15s;
}
.btn-logout:hover { color: var(--danger); }
.btn-logout svg { width: 16px; height: 16px; }

.main-content {
  margin-left: 220px; flex: 1; padding: 28px 32px;
  max-width: calc(100vw - 220px);
}

/* Views */
.view { display: none; }
.view.active { display: block; }

.page-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 600; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px;
}
.stat-card.accent { border-color: var(--accent); background: rgba(79,110,247,0.08); }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Cards */
.section-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.section-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* Search */
.search-bar { margin-bottom: 16px; }
.search-bar input { width: 320px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; font-size: 13.5px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-paid { background: var(--paid-bg); color: var(--success); }
.badge-active { background: var(--active-bg); color: var(--accent); }
.badge-draft { background: rgba(123,130,160,0.15); color: var(--text-muted); }
.badge-cancelled { background: rgba(239,68,68,0.12); color: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 13.5px; font-weight: 500; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 6px; background: transparent; border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-actions { display: flex; gap: 6px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.field small { font-size: 11px; color: var(--text-muted); }
.req { color: var(--accent); }
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text); padding: 9px 12px; font-size: 13.5px; font-family: inherit;
  outline: none; transition: border-color 0.15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--surface2); }
textarea { resize: vertical; min-height: 60px; }

.subdomain-input { display: flex; align-items: center; gap: 0; }
.subdomain-input input { border-radius: 7px 0 0 7px; width: auto; flex: 1; }
.subdomain-suffix {
  background: var(--surface); border: 1px solid var(--border); border-left: none;
  border-radius: 0 7px 7px 0; padding: 9px 12px; color: var(--text-muted);
  font-size: 13px; white-space: nowrap;
}

.error-msg { color: var(--danger); font-size: 12px; text-align: center; padding: 8px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-box {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  width: 100%; margin: 20px;
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-large { max-width: 860px; }
.modal-small { max-width: 420px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 22px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0;
}

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.form-grid .full-width { grid-column: 1 / -1; }

/* Items section */
.items-section { }
.items-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.items-header h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.items-table-wrap { overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
  text-align: left;
}
.items-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.items-table tr:last-child td { border-bottom: none; }
.items-table input {
  padding: 6px 8px; font-size: 13px; border-radius: 6px;
}
.num-col { width: 100px; }
.act-col { width: 40px; }
.items-table tfoot td { padding: 10px; }
.total-label { text-align: right; font-weight: 600; font-size: 13px; color: var(--text-muted); }
.total-value { font-weight: 700; font-size: 15px; color: var(--success); }

/* Link cell */
.invoice-link { color: var(--accent); text-decoration: none; font-size: 12px; }
.invoice-link:hover { text-decoration: underline; }

/* Copy btn */
.copy-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 2px 4px; font-size: 11px;
}
.copy-btn:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 20px; font-size: 13px;
  box-shadow: var(--shadow); animation: fadeIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Amount */
.amount-cell { font-weight: 600; color: var(--text); }

/* Status colors in table */
.subdomain-cell { font-family: monospace; font-size: 12.5px; color: var(--text-muted); }
