:root {
  --blue: #1f457b;
  --blue-strong: #2d69ad;
  --blue-soft: #eaf2ff;
  --green: #07927d;
  --green-soft: #e9fff7;
  --purple: #7d2ee8;
  --ink: #0f1726;
  --muted: #6e7892;
  --line: #dfe5ee;
  --bg: #f2f5f9;
  --danger: #ffefef;
  --danger-border: #ff8d8d;
  font-family: Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(135deg, #214477, #2f6dab);
}

body.admin-open .login-screen,
body:has(#adminShell:target) .login-screen {
  display: none;
}

.login-card {
  width: min(525px, 100%);
  min-height: 624px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 45px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(11, 33, 65, 0.22);
}

.login-card img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  margin-bottom: 22px;
}

.login-card h1 {
  margin: 0 0 10px;
  color: #12376b;
  font-size: 28px;
}

.login-card p {
  margin: 0 0 36px;
  color: #77809c;
  font-size: 17px;
}

.login-form {
  width: 100%;
  display: grid;
  gap: 20px;
}

.login-form label,
.import-panel label,
.word-form label {
  display: grid;
  gap: 10px;
  color: #283650;
  font-weight: 700;
}

.login-form input,
.import-panel select,
.word-form input,
.word-form select,
.word-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  background: #eaf2ff;
  font-weight: 500;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 74px;
}

.password-field button {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 1px solid #c9d5e7;
  border-radius: 6px;
  padding: 6px 8px;
  color: #1f457b;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.login-form > button,
.primary-btn,
.admin-search button {
  border: 0;
  border-radius: 9px;
  padding: 15px 24px;
  color: #fff;
  background: var(--blue-strong);
  font-weight: 800;
}

.login-form > button {
  margin-top: 6px;
  font-size: 20px;
}

.login-form small {
  min-height: 18px;
  color: #c02121;
  font-weight: 600;
}

.return-link {
  margin-top: 24px;
  color: #77809c;
}

.admin-shell {
  min-height: 100vh;
  display: none;
  grid-template-columns: 300px 1fr;
}

body.admin-open .admin-shell,
.admin-shell:target {
  display: grid;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #203f72;
  color: rgba(255, 255, 255, 0.68);
}

.admin-brand {
  display: block;
  padding: 18px 18px 8px;
}

.admin-brand img {
  width: 72px;
  height: 36px;
  object-fit: contain;
}

.sidebar-title {
  margin: 0;
  padding: 8px 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.admin-nav {
  display: grid;
  padding-top: 56px;
}

.admin-nav button,
.sidebar-bottom button,
.sidebar-bottom a {
  width: 100%;
  border: 0;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px 24px;
  color: inherit;
  background: transparent;
  text-align: left;
  font-weight: 800;
  font-size: 17px;
}

.admin-nav button.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 4px 0 0 #38d098;
}

.admin-nav span {
  width: 22px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 18px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-main {
  min-width: 0;
  padding: 28px 34px 60px;
}

.admin-view {
  display: none;
}

.admin-view.is-active {
  display: block;
}

.view-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 36px;
}

.view-heading h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 4vw, 38px);
}

.view-heading p {
  margin: 0;
  color: #71809f;
  font-size: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.stat-card,
.panel,
.help-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(22, 39, 69, 0.08);
}

.stat-card {
  padding: 36px 30px 28px;
}

.stat-card span {
  display: block;
  margin-bottom: 24px;
  color: #58647c;
}

.stat-card strong {
  display: block;
  color: #1a3668;
  font-size: 44px;
  letter-spacing: 0.05em;
}

.stat-card i {
  display: block;
  height: 5px;
  margin-top: 10px;
  border-radius: 999px;
  background: #bcc6d4;
}

.stat-green strong {
  color: #006b55;
}

.stat-green i {
  background: #a9c9c1;
}

.stat-purple strong {
  color: #6e24ca;
}

.stat-purple i {
  background: #c6b0e8;
}

.panel {
  padding: 30px;
  margin-bottom: 30px;
}

.panel h2,
.help-panel h2 {
  margin: 0 0 24px;
  font-size: 22px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.quick-actions button,
.quick-actions a {
  min-width: 184px;
  border: 0;
  border-radius: 10px;
  display: grid;
  gap: 8px;
  padding: 16px 24px;
  color: #fff;
  background: var(--blue);
  text-align: left;
}

.quick-actions button:nth-child(2) {
  background: var(--green);
}

.quick-actions button:nth-child(3) {
  background: var(--blue-strong);
}

.quick-actions button:nth-child(4) {
  background: var(--purple);
}

.quick-actions a {
  background: #3c4658;
}

.quick-actions small {
  color: rgba(255, 255, 255, 0.75);
}

.help-panel {
  padding: 28px 34px;
  background: linear-gradient(120deg, #eef7ff, #edfff8);
  border-color: #cce5ff;
}

.help-panel p {
  margin: 10px 0 0 24px;
  color: #253650;
  font-size: 17px;
}

.import-panel {
  display: grid;
  gap: 24px;
  max-width: none;
}

.import-panel label {
  max-width: 350px;
}

.import-panel input[type="file"] {
  padding: 8px 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.secondary-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 15px 24px;
  color: #23314a;
  background: #f8fafc;
  font-weight: 800;
}

.import-note {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.preview-table {
  max-height: 320px;
  overflow: auto;
}

.preview-table table,
.words-table {
  width: 100%;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td,
.words-table th,
.words-table td {
  border-top: 1px solid #edf0f4;
  padding: 16px 20px;
  text-align: left;
  vertical-align: top;
}

.words-table th {
  color: #5b667b;
  background: #f8fafc;
  text-transform: uppercase;
  font-size: 14px;
}

.admin-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding-bottom: 20px;
}

.admin-search input {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 15px 18px;
  font-size: 17px;
}

.table-panel {
  padding: 20px 0 0;
  overflow: hidden;
}

.table-panel .admin-search {
  padding-left: 26px;
  padding-right: 26px;
}

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

.entry-cell {
  min-width: 320px;
  color: #0f3d7a;
  font-weight: 800;
  line-height: 1.5;
}

.phonetic-cell {
  color: #1354bd;
  font-family: Consolas, monospace;
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--blue-soft);
  color: #1c5eb9;
  font-size: 14px;
  font-weight: 800;
}

.pill.be {
  color: #a94d15;
  background: #fff3e5;
}

.pill.ch {
  color: #7c1f55;
  background: #ffeaf5;
}

.row-actions,
.audio-actions {
  display: flex;
  gap: 8px;
}

.row-actions button,
.audio-actions button {
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 800;
}

.edit-btn,
.generate-btn {
  border: 1px solid #9ce7bd;
  color: #00713e;
  background: #effff5;
}

.delete-btn {
  border: 1px solid var(--danger-border);
  color: #e60000;
  background: var(--danger);
}

.listen-btn {
  border: 0;
  color: #fff;
  background: #43bf75;
}

.range-tabs {
  display: flex;
  gap: 10px;
}

.range-tabs button {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px 22px;
  background: #fff;
  font-weight: 800;
}

.range-tabs button.is-active {
  color: #fff;
  background: var(--blue-strong);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
}

.bar-row {
  margin: 0 0 16px;
}

.bar-row header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
  font-size: 18px;
}

.bar-row small {
  color: #99a1b3;
  font-weight: 700;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0f1f4;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue-strong);
}

.bar-fill.green {
  background: var(--green);
}

.word-dialog {
  width: min(760px, calc(100% - 28px));
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(11, 33, 65, 0.28);
}

.word-dialog::backdrop {
  background: rgba(13, 25, 45, 0.58);
}

.word-form {
  display: grid;
  gap: 18px;
  padding: 26px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-heading h2 {
  margin: 0;
}

.dialog-heading button {
  border: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 980px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-nav {
    display: flex;
    overflow-x: auto;
    padding: 10px;
  }

  .admin-nav button {
    white-space: nowrap;
  }

  .sidebar-bottom {
    display: none;
  }

  .stat-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-main {
    padding: 22px 16px 44px;
  }

  .view-heading,
  .view-heading.with-action,
  .admin-search {
    grid-template-columns: 1fr;
    display: grid;
  }

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