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

body {
  min-height: 100vh;
  background: #0d0d0d;
  color: #fff;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
}

.topbar h1 { font-size: 1.1rem; color: #6b8c5a; letter-spacing: -0.3px; }

.topbar nav { display: flex; gap: 6px; }

.topbar nav a {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #999;
  text-decoration: none;
  transition: all 0.15s;
}

.topbar nav a:hover, .topbar nav a.active { background: #6b8c5a; color: #fff; }

.logout-btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #999;
  background: transparent;
  border: 1px solid #2a2a2a;
  cursor: pointer;
}
.logout-btn:hover { border-color: #666; color: #fff; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px; }

.card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
}

.card h2 { font-size: 1rem; margin-bottom: 18px; color: #fff; }

.center-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card { width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; font-size: 1.3rem; color: #6b8c5a; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: #666; font-size: 0.82rem; margin-bottom: 24px; }

.tabs { display: flex; gap: 4px; background: #111; border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.tab { flex: 1; padding: 8px; text-align: center; font-size: 0.85rem; font-weight: 600; border-radius: 7px; cursor: pointer; color: #666; transition: all 0.2s; user-select: none; }
.tab.active { background: #6b8c5a; color: #fff; }

.form-group { margin-bottom: 14px; }
label { display: block; font-size: 0.78rem; color: #999; margin-bottom: 6px; font-weight: 500; }

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  color: #fff;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: #6b8c5a; }
input::placeholder, textarea::placeholder { color: #444; }
textarea { resize: vertical; min-height: 70px; }

.btn {
  padding: 11px 18px;
  background: #6b8c5a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: #5a7a4a; }
.btn.full { width: 100%; }
.btn.secondary { background: #2a2a2a; }
.btn.secondary:hover { background: #3a3a3a; }
.btn.danger { background: #8c3a3a; }
.btn.danger:hover { background: #7a2f2f; }
.btn.small { padding: 6px 12px; font-size: 0.78rem; }

.error-msg { color: #d97878; font-size: 0.82rem; margin-top: 10px; text-align: center; min-height: 1em; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.75rem; color: #999; text-transform: uppercase; letter-spacing: 0.4px; padding: 10px 12px; border-bottom: 1px solid #2a2a2a; }
td { padding: 12px; border-bottom: 1px solid #222; font-size: 0.88rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #1f1f1f; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; text-transform: capitalize; }
.badge.draft { background: #333; color: #ccc; }
.badge.sent { background: #3a5a8c; color: #cde; }
.badge.paid, .badge.accepted { background: #3a6b3a; color: #cfc; }
.badge.overdue, .badge.expired { background: #8c6a3a; color: #fec; }
.badge.cancelled { background: #6b3a3a; color: #fcc; }

.row-actions { display: flex; gap: 6px; align-items: center; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.toolbar h2 { margin-bottom: 0; }

.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 16px; padding: 26px; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-bottom: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.item-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row input { padding: 8px 10px; font-size: 0.85rem; }
.item-amount { padding: 8px 10px; font-size: 0.85rem; color: #8cbf78; font-weight: 600; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.totals-line { display: flex; justify-content: flex-end; gap: 16px; padding: 10px 0; font-size: 0.9rem; color: #999; }
.totals-line.grand { color: #fff; font-weight: 700; font-size: 1.05rem; border-top: 1px solid #2a2a2a; }

.empty-state { text-align: center; color: #555; padding: 40px 0; font-size: 0.88rem; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.helper-text { color: #666; font-size: 0.78rem; margin-top: 4px; }

.logo-preview { width: 90px; height: auto; border-radius: 8px; margin-bottom: 10px; background: #111; padding: 6px; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 700px) {
  .container { padding: 16px; }
  .card { padding: 18px; border-radius: 12px; }

  .topbar { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .topbar h1 { width: 100%; }
  .topbar nav { flex: 1; flex-wrap: wrap; gap: 4px; }
  .topbar nav a { padding: 7px 10px; font-size: 0.8rem; }
  .logout-btn { padding: 7px 10px; font-size: 0.75rem; }

  .toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar .btn { width: 100%; }

  .grid-2 { grid-template-columns: 1fr; }

  table { font-size: 0.82rem; min-width: 560px; }
  th, td { padding: 9px 8px; }

  .modal { padding: 18px; border-radius: 12px; max-height: 92vh; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }

  .item-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "desc desc" "qty rate" "amount amount" "remove remove";
  }
  .item-row .item-desc { grid-area: desc; }
  .item-row .item-qty { grid-area: qty; }
  .item-row .item-rate { grid-area: rate; }
  .item-row .item-amount { grid-area: amount; }
  .item-row button { grid-area: remove; width: 100%; }

  .row-actions { flex-wrap: wrap; }

  .login-card { max-width: 100%; }
}
