:root {
  --bg: #000000;
  --panel: #0e0e0e;
  --panel-2: #141414;
  --line: #2a2a2a;
  --blue: #1b9bd1;
  --blue-dark: #1685b6;
  --text: #e8e8e8;
  --muted: #9aa0a6;
  --paid: #2fa84f;
  --unpaid: #e05a4e;
}

* { box-sizing: border-box; }
/* The [hidden] attribute must always win over any display rule below
   (e.g. .login-wrap{display:flex}), otherwise hidden views stay visible. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button { font-family: inherit; cursor: pointer; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px 28px;
}
.login-brand {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  text-align: center;
}
.login-sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}
.login-error { color: var(--unpaid); font-size: 14px; margin: 0 0 12px; }

/* ---------------- Topbar ---------------- */
.topbar {
  background: var(--blue);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
.topbar-brand { font-weight: 800; font-size: 22px; letter-spacing: 2px; color: #fff; }
.icon-btn {
  background: transparent; border: none; color: #fff; font-size: 22px; line-height: 1;
}

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: calc(100vh - 60px - 44px); }
.sidebar {
  width: 260px;
  background: #080808;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  flex-shrink: 0;
}
.profile { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel-2); display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--blue);
}
.profile-name { font-weight: 700; }
.profile-role { color: var(--blue); font-size: 13px; }
.nav-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 8px 0 12px; }
.nav { display: flex; flex-direction: column; gap: 10px; }
.nav-item {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 13px 14px;
  border-radius: 8px;
  font-size: 15px;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { border-color: var(--blue); color: #fff; }

/* ---------------- Content ---------------- */
.content { flex: 1; padding: 26px 30px; min-width: 0; }
.content h1 { font-size: 24px; margin: 0 0 18px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}

/* form grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field { display: flex; flex-direction: column; }
.field.span2 { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.field input {
  padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}
.field input:focus { outline: none; border-color: var(--blue); }

.btn-primary {
  margin-top: 20px;
  background: var(--blue);
  border: none;
  color: #fff;
  padding: 12px 26px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-ghost:hover { border-color: var(--blue); }
.btn-danger {
  background: var(--unpaid);
  border: none; color: #fff;
  padding: 11px 22px; border-radius: 6px; font-weight: 600;
}

.created-box {
  margin-top: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.link-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.link-row input {
  flex: 1; min-width: 220px;
  padding: 9px 12px;
  background: #000; border: 1px solid var(--line); border-radius: 6px; color: var(--blue);
}

/* list */
.list-tools { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.list-tools input {
  flex: 1; min-width: 200px;
  padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--text);
}
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
  text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 600; }
.data-table .num { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

.pill {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  padding: 4px 10px; border-radius: 999px; color: #fff; text-transform: uppercase;
}
.pill.paid { background: var(--paid); }
.pill.unpaid { background: var(--unpaid); }

.row-link { color: var(--blue); }
.act-btns { display: flex; gap: 6px; }
.toggle-btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 6px 10px; border-radius: 6px; font-size: 13px;
}
.toggle-btn.mark-paid { border-color: var(--paid); color: var(--paid); }
.toggle-btn.mark-unpaid { border-color: var(--unpaid); color: var(--unpaid); }
.del-btn {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 6px 9px; border-radius: 6px; font-size: 13px;
}

.reset-msg { color: var(--paid); margin-top: 14px; }

/* branding */
.panel-hint { color: var(--muted); margin: 0 0 18px; }
.logo-controls { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.logo-preview {
  width: 220px; min-height: 90px;
  border: 1px dashed var(--line); border-radius: 8px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 10px; text-align: center;
}
.logo-preview img { max-width: 100%; max-height: 80px; object-fit: contain; }
.logo-placeholder { color: #888; font-size: 13px; }
.logo-inputs { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 240px; }
.logo-inputs .mini { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.logo-inputs .mini input[type="text"],
.logo-inputs .mini input[type="file"] {
  padding: 9px 10px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text);
}
.logo-inputs .btn-ghost { align-self: flex-start; }
.save-msg { color: var(--paid); margin-left: 14px; font-weight: 600; }

.color-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-row input[type="color"] {
  width: 46px; height: 40px; padding: 2px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.hex-input { width: 110px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
.color-hint { color: var(--muted); font-size: 12px; }

/* header logo image (shared by topbar + login) */
.brand-logo-img { max-height: 36px; max-width: 200px; object-fit: contain; vertical-align: middle; display: block; }
.login-brand .brand-logo-img { max-height: 56px; margin: 0 auto; }

.app-footer {
  height: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--line);
}

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--blue); color: #fff;
  padding: 12px 20px; border-radius: 8px; z-index: 50;
}

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .grid { grid-template-columns: 1fr; }
}
