:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success-bg: #064e3b;
  --success-text: #6ee7b7;
  --error-bg: #450a0a;
  --error-text: #fca5a5;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(160deg, #0b1020 0%, #111827 45%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

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

.login-panel {
  width: min(400px, 100%);
  padding: 1.5rem;
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.lang-switch {
  font-size: 0.85rem;
  color: var(--muted);
}

.lang-switch a {
  color: #93c5fd;
  text-decoration: none;
}

.lang-switch a:hover {
  text-decoration: underline;
}

.lang-active {
  color: var(--text);
  font-weight: 600;
}

.login-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

h1 { margin: 0; font-size: 1.75rem; font-weight: 700; }

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

select,
input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}

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

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #065f46;
}

.alert.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: #7f1d1d;
}

.hidden { display: none !important; }

.panel {
  background: rgba(26, 35, 50, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { margin: 0; font-size: 1.1rem; }

.panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.panel-actions a.btn {
  text-decoration: none;
}

.table-wrap { overflow-x: auto; }

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

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  vertical-align: middle;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(15, 20, 25, 0.35);
}

td.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.record-name,
.record-content {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
}

.record-content {
  max-width: 320px;
  word-break: break-all;
}

.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-size: 0.78rem;
  font-weight: 600;
}

.actions { display: flex; gap: 0.4rem; }

.btn,
a.btn {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
}

.btn:hover,
a.btn:hover { background: var(--border); }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.primary:hover { background: var(--primary-hover); }

.btn.danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn.danger:hover { background: rgba(239, 68, 68, 0.15); }

.btn.small { padding: 0.3rem 0.55rem; font-size: 0.82rem; }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(480px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

#record-form {
  padding: 1.25rem;
  display: grid;
  gap: 0.85rem;
}

#record-form h3 { margin: 0 0 0.25rem; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

@media (max-width: 720px) {
  .header { flex-direction: column; }
}
