:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #f1f5f4;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #d8dee4;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b91c1c;
  --warning: #b7791f;
  --accent: #2563eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

a { color: inherit; }
.shell {
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--primary);
  color: white;
}
.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.page {
  width: min(1440px, calc(100% - 32px));
  margin: 22px auto;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}
.app-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
}
.app-card:hover { border-color: var(--primary); }
.app-card-icon {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--icon-bg, #e7f5f2);
  color: var(--icon-fg, var(--primary-dark));
}
.app-card-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tab-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--panel);
  cursor: pointer;
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
input, select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
}
.inline-edit-row td {
  background: #eef6f4;
}
.inline-edit-input {
  width: 100%;
  min-width: 90px;
}
button, .button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
}
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: #efb2b2; }
button.warning { color: var(--warning); border-color: #e2c078; }
button.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.export-button:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
button.export-button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.export-button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; min-width: 900px; border-collapse: collapse; background: #fff; }
th, td {
  padding: 9px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
th { background: #eef2f4; text-align: left; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
tr:last-child td { border-bottom: 0; }
.table-group-row td {
  background: #f6f8f9;
  border-top: 2px solid #c7d0da;
  border-bottom: 1px solid #c7d0da;
  font-weight: 700;
}
.table-group-title {
  color: var(--text);
}
.table-group-count {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
tfoot td {
  background: #e2e8f0;
  border-top: 2px solid #c7d0da;
  font-weight: 700;
}
.actions { display: flex; gap: 6px; white-space: nowrap; }
td.center .actions { justify-content: center; }
.message {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
}
.message.error { border-color: #efb2b2; color: var(--danger); }
.message.success { border-color: #9bd4cb; color: var(--primary-dark); }
.import-panel {
  margin: -2px 0 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.import-file {
  flex: 1 1 280px;
}
.import-report {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}
.import-summary strong {
  color: var(--text);
}
.import-report-table {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.import-report-table table {
  min-width: 760px;
}
.import-row-error td {
  background: #fff5f5;
  color: var(--danger);
}
.import-row-create td {
  background: #f0fdf4;
}
.import-row-update td {
  background: #eff6ff;
}
.dict-layout {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 16px;
}
.dict-list {
  display: grid;
  gap: 8px;
}
.dict-section {
  display: grid;
  gap: 8px;
}
.dict-section h3 {
  margin: 0;
  font-size: 15px;
}
.dict-archive-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.dict-archive-section h3 {
  color: var(--muted);
}
.dict-empty {
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.dict-row {
  display: grid;
  grid-template-columns: 70px minmax(160px, 1fr) 90px auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.dict-row-archived {
  background: #f3f4f6;
  border-color: #c7cdd4;
}
.dict-row-archived input {
  background: #eef0f2;
  color: #6b7280;
}
.dict-row-editing {
  background: #eef6f4;
}
.dict-value,
.dict-order {
  min-height: 32px;
  display: flex;
  align-items: center;
}
.dict-order {
  justify-content: flex-end;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.archive-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #c7cdd4;
  border-radius: 6px;
  background: #e5e7eb;
  color: #4b5563;
  font-size: 12px;
}
.archived { color: var(--muted); text-decoration: line-through; }
.muted { color: var(--muted); }
.dictionary-import-help { margin: 12px 0; line-height: 1.6; }
.dictionary-import-help p { margin: 8px 0; }
.dictionary-import-help details { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; }
.dictionary-import-help summary { cursor: pointer; color: var(--primary-dark); font-weight: 600; }
.dictionary-import-help li { margin: 7px 0; }
.import-row-skip { color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .app-grid { grid-template-columns: 1fr; }
  .dict-layout { grid-template-columns: 1fr; }
  .dict-row { grid-template-columns: 1fr; }
}

@media (min-width: 761px) and (max-width: 1080px) {
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
