
:root{
  --bg:#0b1020;
  --panel:#ffffff;
  --panel-2:#f8fafc;
  --line:#dbe4f0;
  --text:#0f172a;
  --muted:#64748b;
  --brand:#2563eb;
  --brand-2:#1d4ed8;
  --success:#16a34a;
  --warning:#d97706;
  --danger:#dc2626;
  --radius:20px;
  --shadow:0 20px 40px rgba(15,23,42,.08);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:#eef2ff;color:var(--text)}
body.auth-page{min-height:100vh;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at top left,#1e3a8a,#0f172a 55%)}
a{color:var(--brand);text-decoration:none}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
.hidden{display:none!important}

.auth-shell{
  width:min(980px,92vw);
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:28px;
  align-items:stretch;
}
.auth-hero,.auth-card{
  background:rgba(255,255,255,.95);
  border-radius:28px;
  box-shadow:var(--shadow);
}
.auth-hero{
  padding:38px;
  background:linear-gradient(140deg,#eff6ff,#dbeafe);
}
.auth-hero h1{margin:0 0 12px;font-size:42px;line-height:1.05}
.auth-hero p{margin:0 0 18px;color:#334155;line-height:1.7}
.auth-badges{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}
.auth-badge{
  background:#fff;
  border:1px solid #bfdbfe;
  padding:10px 14px;
  border-radius:999px;
  color:#1e3a8a;
  font-weight:600;
}
.auth-card{padding:32px}
.auth-card h2{margin:0 0 8px}
.auth-card p{margin:0 0 20px;color:var(--muted)}

.form-group{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
.form-group label{font-weight:600;font-size:14px}
.form-group input,
.form-group select,
.form-group textarea{
  width:100%;
  border:1px solid var(--line);
  background:#fff;
  border-radius:14px;
  padding:12px 14px;
  outline:none;
}
.form-group textarea{min-height:90px;resize:vertical}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.form-grid-3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.form-actions{display:flex;gap:12px;flex-wrap:wrap}
.btn{
  border:none;
  border-radius:14px;
  padding:12px 16px;
  font-weight:700;
  transition:.2s ease;
}
.btn:hover{transform:translateY(-1px)}
.btn-primary{background:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-2)}
.btn-secondary{background:#e2e8f0;color:#0f172a}
.btn-ghost{background:#fff;border:1px solid var(--line);color:#0f172a}
.btn-danger{background:var(--danger);color:#fff}
.btn-success{background:var(--success);color:#fff}
.btn-warning{background:var(--warning);color:#fff}
.btn-sm{padding:8px 12px;border-radius:12px;font-size:13px}

.app{
  display:grid;
  grid-template-columns:280px 1fr;
  min-height:100vh;
}
.sidebar{
  background:#0f172a;
  color:#fff;
  padding:24px;
  position:sticky;
  top:0;
  height:100vh;
}
.brand{display:flex;align-items:center;gap:12px;margin-bottom:26px}
.brand-mark{
  width:48px;height:48px;border-radius:18px;background:linear-gradient(135deg,#60a5fa,#1d4ed8);
  display:grid;place-items:center;font-size:22px;font-weight:800;
}
.brand h1{font-size:22px;margin:0}
.brand p{margin:2px 0 0;color:#cbd5e1;font-size:13px}
.user-box{
  padding:14px;
  border:1px solid rgba(255,255,255,.1);
  border-radius:20px;
  background:rgba(255,255,255,.06);
  margin-bottom:20px;
}
.user-box strong{display:block}
.user-box span{color:#cbd5e1;font-size:13px}
.nav{display:flex;flex-direction:column;gap:8px}
.nav button{
  border:none;
  text-align:left;
  padding:13px 14px;
  border-radius:14px;
  background:transparent;
  color:#e2e8f0;
  font-weight:700;
}
.nav button.active,
.nav button:hover{
  background:#1e293b;
  color:#fff;
}
.sidebar-footer{
  position:absolute;
  bottom:24px;
  left:24px;
  right:24px;
}
.main{
  padding:28px;
}
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:22px;
}
.topbar h2{margin:0;font-size:30px}
.topbar p{margin:4px 0 0;color:var(--muted)}
.card{
  background:var(--panel);
  border-radius:24px;
  box-shadow:var(--shadow);
  padding:22px;
}
.card + .card{margin-top:18px}
.cards{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:18px;
}
.metric{
  background:linear-gradient(180deg,#fff,#f8fbff);
  border:1px solid #e5eef9;
  border-radius:22px;
  padding:20px;
}
.metric .label{font-size:13px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.04em}
.metric .value{font-size:32px;font-weight:800;margin-top:6px}
.metric .note{font-size:13px;color:var(--muted);margin-top:6px}
.table-wrap{overflow:auto}
table{
  width:100%;
  border-collapse:collapse;
}
th,td{
  padding:14px 12px;
  border-bottom:1px solid #ecf0f7;
  text-align:left;
  vertical-align:top;
  white-space:nowrap;
}
th{font-size:13px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:7px 12px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
}
.badge.unpaid{background:#fee2e2;color:#991b1b}
.badge.dp{background:#fef3c7;color:#92400e}
.badge.paid{background:#dcfce7;color:#166534}

.toolbar{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:18px}
.search{
  min-width:280px;
}
.search input{
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  background:#fff;
}
.inline-actions{display:flex;gap:8px;flex-wrap:wrap}
.inline-actions a{display:inline-flex}
.section{display:none}
.section.active{display:block}

dialog{
  border:none;
  border-radius:24px;
  width:min(1200px,96vw);
  max-height:92vh;
  padding:0;
  overflow:hidden;
  box-shadow:0 30px 80px rgba(2,6,23,.28);
}
dialog::backdrop{background:rgba(15,23,42,.55)}
.dialog-header{
  padding:18px 22px;
  border-bottom:1px solid #edf2f7;
  display:flex;
  justify-content:space-between;
  align-items:center;
  background:#fff;
}
.dialog-body{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:0;
  background:#f8fafc;
}
.dialog-panel{
  padding:22px;
  overflow:auto;
  max-height:calc(92vh - 72px);
  background:#fff;
}
.dialog-preview{
  padding:22px;
  overflow:auto;
  max-height:calc(92vh - 72px);
  background:#f8fafc;
  border-left:1px solid #edf2f7;
}
.invoice-items{
  border:1px solid var(--line);
  border-radius:18px;
  overflow:hidden;
  margin-bottom:16px;
}
.invoice-item-row{
  display:grid;
  grid-template-columns:1.2fr 1.4fr .8fr .7fr .9fr .9fr auto;
  gap:10px;
  padding:12px;
  border-bottom:1px solid #edf2f7;
  align-items:start;
}
.invoice-item-row.header{
  background:#f8fafc;
  font-weight:700;
  color:var(--muted);
  text-transform:uppercase;
  font-size:12px;
}
.invoice-item-row:last-child{border-bottom:none}
.preview-sheet{
  background:#fff;
  border:1px solid #dbe4f0;
  border-radius:22px;
  padding:24px;
  box-shadow:0 10px 20px rgba(15,23,42,.04);
}
.preview-sheet h3{margin:0}
.preview-head{
  display:flex;
  justify-content:space-between;
  gap:18px;
  margin-bottom:18px;
  padding-bottom:14px;
  border-bottom:2px solid #0f172a;
}
.preview-sub{color:var(--muted);line-height:1.6;font-size:14px}
.preview-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:16px}
.preview-box{
  border:1px solid #dbe4f0;
  border-radius:16px;
  padding:14px;
  background:#fff;
}
.preview-table{width:100%;border-collapse:collapse;margin-top:10px}
.preview-table th,.preview-table td{white-space:normal;padding:10px;border:1px solid #dbe4f0}
.preview-table th{background:#f8fafc}
.summary-table{width:320px;max-width:100%;margin-left:auto;margin-top:14px;border-collapse:collapse}
.summary-table td{border:1px solid #dbe4f0;padding:10px}
.summary-table tr.total td{font-weight:800;background:#e2e8f0}
.public-wrap{
  max-width:980px;
  margin:28px auto;
  padding:0 16px 32px;
}
.public-actions{display:flex;gap:12px;flex-wrap:wrap;margin-bottom:18px}
.notice{
  padding:14px 16px;
  border-radius:14px;
  margin-bottom:14px;
  font-weight:600;
}
.notice.info{background:#e0f2fe;color:#075985}
.notice.error{background:#fee2e2;color:#991b1b}
.muted{color:var(--muted)}
.empty-state{
  padding:28px;
  text-align:center;
  color:var(--muted);
  border:1px dashed #cbd5e1;
  border-radius:18px;
}
@media (max-width:1080px){
  .dialog-body{grid-template-columns:1fr}
  .dialog-preview{border-left:none;border-top:1px solid #edf2f7}
  .cards{grid-template-columns:1fr 1fr}
}
@media (max-width:860px){
  .auth-shell{grid-template-columns:1fr}
  .app{grid-template-columns:1fr}
  .sidebar{position:relative;height:auto}
  .sidebar-footer{position:static;margin-top:18px}
  .cards{grid-template-columns:1fr}
  .form-grid,.form-grid-3,.preview-grid{grid-template-columns:1fr}
  .invoice-item-row{grid-template-columns:1fr}
}
