:root {
  --bg: #0f1419;
  --card: #1a2129;
  --border: #2a333d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --primary: #2f81f7;
  --green: #2ea043;
  --red: #f85149;
  --yellow: #d29922;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1em; margin: 8px 0 0; }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

#login-form {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#login-form h1 { margin: 0; }
#login-form p { margin: 0; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--primary); }

button {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
}
button:hover { border-color: var(--primary); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--red); border-color: var(--red); }
button.small { padding: 5px 9px; font-size: 12px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 20px; }
header div { display: flex; gap: 8px; }

.stats {
  display: flex;
  gap: 16px;
  padding: 16px 28px;
  flex-wrap: wrap;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  min-width: 120px;
}
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12px; }

table {
  width: calc(100% - 56px);
  margin: 0 28px 28px;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.badge { padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(46,160,67,.15); color: var(--green); }
.badge.bad { background: rgba(248,81,73,.15); color: var(--red); }
.badge.warn { background: rgba(210,153,34,.15); color: var(--yellow); }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
.modal-content { width: 420px; display: flex; flex-direction: column; gap: 10px; }
.modal-content h2 { margin: 0 0 6px; }
.modal-content label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.modal-content label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.modal-content label.checkbox input { width: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.actions-cell { display: flex; gap: 6px; }
.modal-content { max-height: calc(100vh - 40px); overflow-y: auto; }
#f-plan, #f-cycle, #f-windows, #f-period { display: block; width: 100%; margin-top: 4px; padding: 8px; }
#f-price { min-height: 1.5em; }
 
#login-form, #password-form { width: min(420px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 14px; }
#login-form label, #password-form label, .user-form label { display: flex; flex-direction: column; gap: 6px; }
.small { font-size: 12px; }
.panel-tabs { display: flex; gap: 12px; padding: 16px 28px 0; }
.panel-tabs [aria-pressed="true"] { border-color: var(--green); color: #81d392; }
#account-label { display: block; font-weight: 400; margin-top: 5px; }
#panel-error, #users-empty { margin: 12px 28px; }
.team-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 20px 28px; }
.team-toolbar h2 { font-size: 20px; }
.table-scroll { overflow-x: auto; margin: 0 28px 28px; }
.table-scroll table { width: 100%; margin: 0; min-width: 850px; }
td { overflow-wrap: anywhere; max-width: 280px; }
.actions-cell { flex-wrap: wrap; }
dialog { color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 24px; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: #0009; }
.user-form { display: flex; flex-direction: column; gap: 12px; }
.user-form h2, .user-form p { margin: 0; }
.user-form .small { line-height: 1.6; }
button:disabled { opacity: .5; cursor: wait; }
.modal-content { width: min(420px, calc(100vw - 32px)); }
@media(max-width:700px) {
  header { align-items: flex-start; gap: 16px; flex-direction: column; padding: 16px; }
  header div { flex-wrap: wrap; }
  .stats { padding: 16px; gap: 8px; }
  .stat { flex: 1; padding: 12px; }
  .panel-tabs { padding-inline: 16px; }
  .table-scroll { margin-inline: 16px; }
  .team-toolbar { margin-inline: 16px; flex-wrap: wrap; }
}
.table-scroll code { white-space: nowrap; }
#account-limits { margin: 16px 28px 0; font-size: 13px; }
#u-limits { border: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#u-limits legend { color: var(--muted); }
.user-form .limit-toggle { flex-direction: row; align-items: center; }
.limit-toggle input { width: auto; }
#u-seller-limits { display: flex; flex-direction: column; gap: 10px; }
