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

/* -- Tokens-- */
:root {
  --red:        #d1131a;
  --red-hover:  #b81017;
  --red-subtle: rgba(209,19,26,.12);
  --bg:         #0d0d0d;
  --sidebar:    #0a0a0a;
  --surface:    #141414;
  --card:       #181818;
  --card-hover: #1e1e1e;
  --border:     #252525;
  --border-2:   #2e2e2e;
  --text:       #f2f2f2;
  --text-2:     #999;
  --text-3:     #666;
  --green:      #22c55e;
  --yellow:     #f59e0b;
  --blue:       #3b82f6;
  --r:          8px;
  --r-lg:       12px;
}

/* -- Base-- */
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; transition: color .15s; }
a:hover { color: #e83039; }
::selection { background: var(--red); color: #fff; }

/*-- */
/* PORTAL SHELL (sidebar layout)                                               */
/*-- */
.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img { height: 30px; display: block; }
.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}
.sidebar-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-3);
  font-weight: 600;
  padding: 16px 10px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active { background: var(--red-subtle); color: var(--red); }
.sidebar-link.active svg { opacity: 1; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--red-subtle);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--red);
  flex-shrink: 0;
}
.sidebar-user-info .name { font-weight: 600; color: var(--text); font-size: 13px; line-height: 1.2; }
.sidebar-user-info .role { color: var(--text-3); font-size: 11px; }

/* Main content area */
.main { margin-left: 230px; flex: 1; min-width: 0; }

/* Top bar */
.topbar {
  height: 58px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Page content */
.page { padding: 28px; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.page-header .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }

/*-- */
/* STATS                                                                       */
/*-- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: border-color .15s;
}
.stat:hover { border-color: var(--border-2); }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.red  { background: var(--red-subtle); color: var(--red); }
.stat-icon.green { background: rgba(34,197,94,.12); color: var(--green); }
.stat-icon.blue  { background: rgba(59,130,246,.12); color: var(--blue); }
.stat-icon.gray  { background: rgba(255,255,255,.06); color: var(--text-2); }
.stat-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.stat-val { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-val.red { color: var(--red); }
.stat-val.green { color: var(--green); }

/*-- */
/* CARD                                                                        */
/*-- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); }
.card-body { padding: 20px; }
.card-empty { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 14px; }

/*-- */
/* TABLE                                                                       */
/*-- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: #111; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 16px; border-bottom: 1px solid #1d1d1d; vertical-align: middle; font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #1c1c1c; }
.td-muted { color: var(--text-2); font-size: 13px; }
.td-bold { font-weight: 600; }
.td-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; }

/*-- */
/* BADGES                                                                      */
/*-- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-red    { background: rgba(209,19,26,.15);  color: #f87171; border: 1px solid rgba(209,19,26,.3); }
.badge-green  { background: rgba(34,197,94,.12);  color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.badge-yellow { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }
.badge-gray   { background: rgba(255,255,255,.06); color: #666;   border: 1px solid #2e2e2e; }
.badge-blue   { background: rgba(59,130,246,.12); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
/* aliases */
.badge-open   { background: rgba(209,19,26,.15); color: #f87171; border: 1px solid rgba(209,19,26,.3); }
.badge-paid   { background: rgba(34,197,94,.12); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.badge-overdue { background: rgba(209,19,26,.3); color: #fca5a5; border: 1px solid rgba(209,19,26,.5); }
.badge-closed { background: rgba(255,255,255,.06); color: #666; border: 1px solid #2e2e2e; }
.badge-active { background: rgba(34,197,94,.12); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.badge-paused { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }
.badge-cancelled { background: rgba(255,255,255,.06); color: #555; border: 1px solid #2e2e2e; }

/*-- */
/* BUTTONS                                                                     */
/*-- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--r);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  text-decoration: none; transition: all .15s;
  white-space: nowrap; line-height: 1;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--red); color: #fff; }
.btn-primary:hover  { background: var(--red-hover); color: #fff; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--card-hover); color: var(--text); }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover    { color: var(--text); border-color: var(--border-2); background: var(--surface); }
.btn-danger   { background: rgba(127,29,29,.6); color: #fca5a5; border: 1px solid #7f1d1d; }
.btn-danger:hover   { background: #7f1d1d; }
.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

/*-- */
/* FORMS                                                                       */
/*-- */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 16px; }
.form-group:last-of-type { margin-bottom: 0; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 7px;
}
.form-label .optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-3); }
.form-input {
  width: 100%; background: #0f0f0f; border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 13px; color: var(--text);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(209,19,26,.1); }
.form-input::placeholder { color: var(--text-3); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }
.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #111; border: 1px solid var(--border);
  border-radius: var(--r); cursor: pointer; font-size: 13px; color: var(--text-2);
  transition: border-color .15s;
}
.check-row:hover { border-color: var(--border-2); }
.check-row input { width: 15px; height: 15px; accent-color: var(--red); cursor: pointer; }

/*-- */
/* ALERTS                                                                      */
/*-- */
.alert { padding: 12px 16px; border-radius: var(--r); font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: rgba(209,19,26,.1); border: 1px solid rgba(209,19,26,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-info    { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }
.alert-warn    { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fbbf24; }

/*-- */
/* LOGIN PAGE                                                                  */
/*-- */
.login-page {
  min-height: 100vh; display: flex;
  background: var(--bg);
}
.login-left {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 60px 80px;
  background:
    linear-gradient(135deg, rgba(10,0,2,0.82) 0%, rgba(5,5,15,0.75) 100%),
    url('/houston-skyline.jpg') center center / cover no-repeat;
  border-right: 1px solid var(--border);
  position: relative;
}
.login-left .brand img { height: 38px; display: block; margin-bottom: 48px; }
.login-left h1 { font-size: 36px; font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.login-left h1 span { color: var(--red); }
.login-left p { color: var(--text-2); font-size: 16px; line-height: 1.7; max-width: 380px; }
.login-features { margin-top: 40px; display: flex; flex-direction: column; gap: 14px; }
.login-feature { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 14px; }
.login-feature-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.login-right {
  width: 460px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-box .login-sub { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: var(--text-3); }
.login-footer a { color: var(--red); }

/*-- */
/* PAYMENT FORM                                                                */
/*-- */
.pay-tabs {
  display: flex; background: #0f0f0f; border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 4px; margin-bottom: 20px;
}
.pay-tab {
  flex: 1; padding: 10px; background: transparent; border: none;
  border-radius: var(--r); color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.pay-tab.active { background: var(--red); color: #fff; }
.pay-tab:not(.active):hover { background: var(--surface); color: var(--text); }

.fee-card {
  background: #0f0f0f; border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px; margin: 18px 0;
}
.fee-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.fee-row .lbl { color: var(--text-2); }
.fee-row .val { font-weight: 500; }
.fee-sep { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.fee-total .lbl { font-weight: 700; font-size: 15px; color: var(--text); }
.fee-total .val { font-weight: 800; font-size: 22px; color: var(--red); }
.fee-note { font-size: 11px; color: var(--text-3); margin-top: 8px; }

/*-- */
/* INVOICE DETAIL                                                              */
/*-- */
.invoice-header {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 24px; margin-bottom: 20px;
}
.inv-meta-item .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin-bottom: 5px; }
.inv-meta-item .val { font-size: 15px; font-weight: 600; }
.inv-meta-item .val.big { font-size: 24px; color: var(--red); }

/*-- */
/* SUCCESS PAGE                                                                */
/*-- */
.success-wrap { max-width: 520px; margin: 0 auto; padding: 60px 20px; text-align: center; }
.success-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(34,197,94,.1); border: 2px solid rgba(34,197,94,.4);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 24px;
}

/*-- */
/* DIVIDERS / UTILS                                                            */
/*-- */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-2); }
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.fw-bold    { font-weight: 700; }
.mt-4 { margin-top: 4px; }

/*-- */
/* RESPONSIVE                                                                  */
/*-- */
@media (max-width: 900px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
  .login-box { max-width: 420px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .invoice-header { grid-template-columns: 1fr 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}
