:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-border: #d9e0e3;
  --text: #172026;
  --muted: #667780;
  --accent: #236a7a;
  --accent-strong: #174e5b;
  --danger: #9f2f26;
  --danger-bg: #fff0ee;
  --success-bg: #edf8f0;
  --error-bg: #fff1f0;
  --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #e8eef0;
  color: var(--text);
}

button.secondary:hover {
  background: #dce5e8;
}

button.danger {
  min-height: 32px;
  background: var(--danger-bg);
  color: var(--danger);
}

button.danger:hover {
  background: #ffdeda;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input {
  min-height: 42px;
}

textarea {
  min-height: 280px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(35, 106, 122, 0.18);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

.quiet-entry {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #f8fafb;
}

.quiet-form {
  display: grid;
  gap: 8px;
  width: min(100% - 48px, 220px);
}

.quiet-form input {
  min-height: 34px;
  border-color: #eef2f4;
  background: #fff;
  color: #172026;
}

.quiet-submit {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0;
  pointer-events: none;
}

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

.tool-rail {
  grid-row: 1 / 3;
  border-right: 1px solid #cbd5d9;
  background: #1f2b31;
  color: #f8fbfc;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 6px;
  background: #f3c95f;
  color: #1f2b31;
  font-size: 0.8rem;
}

.tool-rail nav {
  display: grid;
  gap: 6px;
}

.tool-link {
  border-radius: 6px;
  color: #dce7ea;
  padding: 10px 12px;
  text-decoration: none;
}

.tool-link.active {
  background: #31424a;
  color: #fff;
}

.tool-link.disabled {
  color: #90a2aa;
}

.workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
}

.tab-link {
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  font-weight: 800;
  padding: 10px 14px;
  text-decoration: none;
}

.tab-link.active {
  border-color: var(--panel-border);
  background: var(--panel);
  color: var(--text);
}

.function-ribbon {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 16px rgba(23, 32, 38, 0.06);
  padding: 8px;
}

.function-ribbon a {
  border-radius: 6px;
  color: var(--text);
  font-weight: 800;
  padding: 8px 12px;
  text-decoration: none;
}

.function-ribbon a:hover {
  background: #e8eef0;
}

.function-ribbon a.active {
  background: var(--accent);
  color: #fff;
}

.workspace {
  min-width: 0;
  overflow: auto;
  padding: 28px;
  scroll-behavior: smooth;
}

.workspace section,
.workspace form[id] {
  scroll-margin-top: 82px;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.05rem;
}

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

.section-stack {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack p {
  margin: 0;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) max-content;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  margin: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
}

.message.success {
  border-color: #b8dfc4;
  background: var(--success-bg);
}

.message.error {
  border-color: #f0bbb7;
  background: var(--error-bg);
}

.table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  border-bottom: 1px solid var(--panel-border);
  padding: 12px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.actions {
  width: 180px;
  text-align: right;
}

.actions form {
  margin: 0;
}

.action-pair {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

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

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-strong);
}

.secondary-link {
  min-height: 32px;
  background: #e8eef0;
  color: var(--text);
}

.secondary-link:hover {
  background: #dce5e8;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 14px 0 0;
}

.metadata-grid div {
  min-width: 0;
}

.metadata-grid dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metadata-grid dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 18px 0 0;
  border: 1px dashed var(--panel-border);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.signal-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
  border-top: 1px solid #cbd5d9;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 18px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .tool-rail {
    grid-row: auto;
    border-right: 0;
    padding: 12px;
  }

  .tool-rail nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .brand {
    margin-bottom: 12px;
  }

  .workspace {
    padding: 18px;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .search-row {
    grid-template-columns: 1fr;
  }

  .signal-bar {
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 12px;
  }
}
