:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-strong: #f0f4f1;
  --text: #18211f;
  --muted: #65706b;
  --line: #dce3de;
  --teal: #0f766e;
  --teal-dark: #0b514d;
  --amber: #b97913;
  --green: #257a44;
  --slate: #53616b;
  --shadow: 0 18px 50px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(185, 121, 19, 0.12), transparent 38%),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.login-panel h1 {
  margin: 22px 0 10px;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.05;
}

.login-panel p {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary-btn,
.ghost-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-btn {
  display: inline-grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
}

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

.primary-btn.full {
  width: 100%;
  margin-top: 18px;
}

.ghost-btn.full {
  width: 100%;
  margin-top: 18px;
}

.ghost-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.danger-btn {
  min-height: 42px;
  border: 1px solid #e8c9c2;
  border-radius: 8px;
  background: #fff7f5;
  color: #9f2f19;
  padding: 0 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.danger-btn:hover {
  border-color: #d89b8e;
  background: #fff0ec;
}

.form-error,
.fatal-error {
  border-radius: 8px;
  background: #fff4f1;
  color: #9f2f19;
  padding: 12px;
  font-weight: 700;
}

.fatal-error {
  margin: 40px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 286px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.group-nav {
  display: grid;
  gap: 8px;
}

.group-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  cursor: pointer;
  text-align: left;
}

.group-nav button:hover,
.group-nav button.active {
  background: var(--surface-strong);
  border-color: var(--line);
}

.group-nav span {
  font-weight: 750;
}

.group-nav small {
  display: grid;
  min-width: 26px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #e4ece8;
  color: var(--teal-dark);
  font-weight: 800;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 16px;
}

.sidebar-note h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

.sidebar-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.topbar-actions button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.notice-message {
  margin: -6px 0 16px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #ecf7f3;
  color: var(--teal-dark);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 750;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 150px 170px 170px 170px;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.search-field input {
  min-width: 0;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--teal);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: 16px;
  align-items: start;
}

.notice-list {
  display: grid;
  gap: 10px;
}

.notice-row,
.details-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(24, 33, 31, 0.04);
}

.notice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 18px;
  padding: 16px;
  cursor: pointer;
}

.notice-row:hover,
.notice-row.selected {
  border-color: rgba(15, 118, 110, 0.45);
}

.notice-row.selected {
  box-shadow: inset 3px 0 0 var(--teal), 0 8px 24px rgba(24, 33, 31, 0.05);
}

.row-meta,
.keyword-line,
.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.notice-row h2 {
  margin: 10px 0 7px;
  font-size: 17px;
  line-height: 1.25;
}

.notice-row p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.keyword-line span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.notice-side {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.notice-side strong {
  font-size: 24px;
}

.notice-side time {
  margin-top: 6px;
  color: var(--text);
  font-weight: 800;
}

.notice-side time.urgent {
  color: #ad3f12;
}

.status {
  display: inline-grid;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
}

.status-green {
  background: #e7f5eb;
  color: var(--green);
}

.status-amber {
  background: #fff3d9;
  color: var(--amber);
}

.status-slate {
  background: #edf1f3;
  color: var(--slate);
}

.score-high {
  color: var(--green);
}

.score-mid {
  color: var(--amber);
}

.score-low {
  color: var(--slate);
}

.details-panel {
  position: sticky;
  top: 24px;
  padding: 20px;
}

.detail-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.details-panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.detail-summary {
  color: var(--muted);
  line-height: 1.55;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.detail-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
}

.requirements {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.requirements h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.requirements ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.ai-analysis-wrap {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.ai-analysis-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-analysis-action h3 {
  margin: 0;
  font-size: 15px;
}

.ai-analysis-action p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ai-analysis-action button {
  flex: 0 0 auto;
}

.ai-analysis-action button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ai-analysis-wrap .form-error {
  margin-top: 12px;
  font-size: 13px;
}

.ai-analysis {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.ai-analysis summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  cursor: pointer;
  font-weight: 850;
}

.ai-analysis summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ai-analysis-body {
  border-top: 1px solid var(--line);
  padding: 15px;
}

.ai-summary {
  margin: 0 0 14px;
  color: var(--text);
  line-height: 1.55;
}

.ai-analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.ai-analysis-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.ai-analysis h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.ai-analysis p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.ai-analysis-body > section {
  margin-top: 14px;
}

.ai-analysis ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.ai-disclaimer {
  margin-top: 16px !important;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 11px;
}

.ai-empty {
  font-size: 13px;
}

.empty-state {
  padding: 28px;
}

.empty-state.compact {
  box-shadow: none;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.settings-page {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.settings-header,
.settings-section-head,
.settings-row,
.category-add {
  display: flex;
  align-items: center;
}

.settings-header {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.settings-header h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.settings-header p,
.settings-section-head p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.settings-section {
  border-top: 1px solid var(--line);
  padding: 26px 0 30px;
}

.settings-section-head {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.settings-section-head h2 {
  margin: 0;
  font-size: 20px;
}

.category-add {
  width: min(430px, 100%);
  gap: 8px;
}

.category-add input {
  min-width: 220px;
}

.settings-category-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.settings-category-list {
  display: grid;
  max-height: 640px;
  gap: 5px;
  overflow-y: auto;
  padding-right: 5px;
}

.settings-category-list button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
}

.settings-category-list button:hover,
.settings-category-list button.active {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--teal-dark);
}

.settings-editor {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.settings-row {
  justify-content: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.settings-row > label:not(.check-label) {
  width: 180px;
}

.settings-row .danger-btn {
  margin-left: auto;
}

.check-label {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
  text-transform: none;
}

.check-label input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--teal);
}

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

.settings-columns textarea {
  min-height: 390px;
}

.algorithm-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.settings-wide-field {
  max-width: 900px;
}

.settings-wide-field textarea {
  min-height: 180px;
}

.email-settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) repeat(2, minmax(190px, 0.8fr));
  gap: 14px;
  align-items: start;
  max-width: 1040px;
}

.email-settings-grid textarea {
  min-height: 116px;
}

@media (max-width: 1040px) {
  .app-shell,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .details-panel {
    position: static;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .group-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-category-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .algorithm-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    flex-direction: column;
  }

  .controls,
  .group-nav,
  .notice-row,
  .detail-grid,
  .settings-category-layout,
  .settings-columns,
  .algorithm-grid,
  .email-settings-grid {
    grid-template-columns: 1fr;
  }

  .notice-side {
    justify-items: start;
  }

  .ai-analysis-action,
  .ai-analysis summary {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-analysis-grid {
    grid-template-columns: 1fr;
  }

  .ai-analysis-action button {
    width: 100%;
  }

  .settings-page {
    padding: 16px;
  }

  .settings-header,
  .settings-section-head,
  .settings-row,
  .category-add {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-header h1 {
    font-size: 28px;
  }

  .category-add,
  .category-add input,
  .settings-row > label:not(.check-label) {
    width: 100%;
    min-width: 0;
  }

  .settings-category-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 230px;
  }

  .settings-editor {
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 18px;
    padding-left: 0;
  }

  .settings-row .danger-btn {
    margin-left: 0;
  }
}
