:root {
  --bg: #f4f6fb;
  --bg-deep: #e8eef8;
  --card: #ffffff;
  --accent: #1a4fbf;
  --accent-hover: #143f99;
  --accent-soft: rgba(26, 79, 191, 0.12);
  --accent-glow: rgba(26, 79, 191, 0.28);
  --red: #c8102e;
  --red-hover: #a50d26;
  --red-soft: rgba(200, 16, 46, 0.12);
  --text: #121826;
  --muted: #5a6478;
  --border: #d5deef;
  --header: linear-gradient(135deg, #0b1f5b 0%, #1a4fbf 48%, #c8102e 100%);
  --header-text: #ffffff;
  --success: #0f7b0f;
  --danger: #c8102e;
  --shadow: 0 10px 28px rgba(11, 31, 91, 0.12);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 0% 0%, var(--red-soft), transparent 34%),
    radial-gradient(circle at 100% 0%, var(--accent-soft), transparent 38%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.15rem 1.5rem;
  background: var(--header);
  color: var(--header-text);
  box-shadow: 0 8px 24px rgba(11, 31, 91, 0.28);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.header-badge {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: #f2f6ff;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.header-badge.accent-badge {
  background: rgba(200, 16, 46, 0.28);
  border-color: rgba(255, 255, 255, 0.4);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, #1a4fbf 0%, #1a4fbf 48%, #c8102e 52%, #c8102e 100%);
  box-shadow: 0 6px 16px rgba(11, 31, 91, 0.28);
  flex-shrink: 0;
}

.brand-mark-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.mono,
td.mono {
  font-family: var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(320px, 3fr);
  gap: 1rem;
  padding: 1rem 1.25rem 1.25rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.single-layout {
  grid-template-columns: 1fr;
  max-width: 760px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--red));
}

.card-header,
.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.card h2,
.card h3,
.detail-top h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: #0b1f5b;
}

.card-header .muted {
  margin: 0.35rem 0 0;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  max-height: 420px;
  background: linear-gradient(180deg, #fbfcff 0%, #f5f8ff 100%);
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
}

.accounts-table th,
.accounts-table td {
  padding: 0.8rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.accounts-table th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #edf2ff 0%, #e7eeff 100%);
  color: #0b1f5b;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 1;
}

.accounts-table td.num,
.accounts-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.accounts-table tbody tr {
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
}

.accounts-table tbody tr:hover:not(.empty) {
  background: var(--accent-soft);
}

.accounts-table tbody tr.selected {
  background: linear-gradient(90deg, rgba(26, 79, 191, 0.16), rgba(200, 16, 46, 0.12));
  color: #0b1f5b;
  font-weight: 600;
}

.accounts-table tbody tr.empty {
  cursor: default;
  color: var(--muted);
  text-align: center;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  font-weight: 650;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease, box-shadow 0.12s ease;
}

.btn:hover {
  background: #f3f6ff;
  border-color: #b8c7ea;
}

.btn:active {
  transform: translateY(1px);
}

.btn.accent {
  background: linear-gradient(135deg, var(--accent) 0%, #2a63d8 55%, #9b1c38 140%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(26, 79, 191, 0.28);
}

.btn.accent:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #1f54c2 55%, var(--red-hover) 140%);
  border-color: transparent;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.danger:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.header-btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top right, rgba(200, 16, 46, 0.22), transparent 34%),
    radial-gradient(circle at bottom left, rgba(26, 79, 191, 0.28), transparent 40%),
    linear-gradient(160deg, #0b1f5b 0%, #163a8a 42%, #7a1838 100%);
}

/* Page stylesheet display rules beat the UA [hidden] rule; restore it. */
[hidden] {
  display: none !important;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 0.9rem;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 18px 40px rgba(8, 18, 54, 0.35);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent), var(--red));
}

.login-brand h1 {
  margin: 0.75rem 0 0;
  font-size: 1.28rem;
  color: #0b1f5b;
}

.login-brand p {
  margin: 0.4rem 0 0;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

.history {
  margin: 0;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #f8faff 0%, #f3f6ff 100%);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(90deg, #edf2ff 0%, #fff5f7 100%);
  font-size: 0.85rem;
  color: var(--muted);
}

#status {
  color: #0b1f5b;
  font-weight: 650;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(360px, calc(100vw - 2rem));
  background: linear-gradient(135deg, #0b1f5b, #1a4fbf);
  color: #fff;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toast.error {
  background: linear-gradient(135deg, #8b0f24, var(--danger));
}

.toast.success {
  background: linear-gradient(135deg, #0b1f5b, #178a3d);
}

/* Customer app auth tabs */
.auth-card {
  width: min(430px, 100%);
}

.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 1rem;
  background: linear-gradient(90deg, rgba(26, 79, 191, 0.1), rgba(200, 16, 46, 0.1));
  padding: 0.28rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

.auth-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(26, 79, 191, 0.16);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.auth-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  text-align: center;
}

.field-hint {
  margin: 0;
  font-size: 0.85rem;
}

.app-nav {
  display: flex;
  gap: 0.45rem;
  padding: 0.85rem 1.5rem 0;
  background: transparent;
}

.nav-tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  padding: 0.58rem 1.05rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.nav-tab:hover {
  border-color: #b7c6ea;
  color: var(--accent);
}

.nav-tab.active {
  background: linear-gradient(135deg, var(--accent), #2a63d8 60%, #b41d3d);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 16px rgba(26, 79, 191, 0.24);
}

.wire-layout {
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 1fr);
}

.wire-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.wire-form select,
.wire-form input {
  width: 100%;
  margin-top: 0.1rem;
}

@media (max-width: 860px) {
  .layout,
  .wire-layout,
  .single-layout {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: column;
  }

  .app-nav {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
