:root {
  color-scheme: light;
  --bg: #f0f4fa;
  --bg-dark: #e6edf7;
  --panel: #ffffff;
  --line: #d4dce8;
  --line-strong: #b8c4d5;
  --text: #1c2b3c;
  --muted: #607086;
  --accent: #1976d2;
  --accent-strong: #155ea6;
  --danger: #c62828;
  --ok: #1e8e3e;
  --shadow: 0 10px 24px rgba(20, 38, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-dark) 0, var(--bg) 220px);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--line-strong);
  background: #f7faff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0f5bb0, #1f8cff);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}

.brand p {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.nav-link {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.session-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.login-card,
.panel-card,
.inbox-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-card {
  max-width: 420px;
  margin: 2.4rem auto;
  padding: 1.2rem;
}

.login-card h2 {
  margin: 0 0 0.3rem;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-card form {
  margin-top: 1rem;
}

label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #33465f;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.55rem 0.66rem;
  color: var(--text);
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #9ac5f8;
  border-color: #6ea9ec;
}

.btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.52rem 0.84rem;
  cursor: pointer;
  font-weight: 700;
}

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

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

.btn-ghost:hover {
  background: #f2f7fd;
}

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

.btn-danger:hover {
  background: #ad2020;
}

.view {
  min-height: 680px;
}

.hidden {
  display: none;
}

.error {
  color: var(--danger);
  min-height: 1.1rem;
  margin-top: 0.5rem;
}

.status-pill {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid #ef9a9a;
  color: #a12424;
  background: #ffebee;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill.ok {
  border-color: #9ad7ae;
  color: #11672d;
  background: #e7f7ec;
}

.inbox-shell {
  display: grid;
  grid-template-columns: minmax(320px, 36%) 1fr;
  min-height: calc(100vh - 170px);
  overflow: hidden;
}

.inbox-list-panel {
  border-right: 1px solid var(--line);
  background: #fbfdff;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar {
  padding: 0.8rem;
}

.toolbar input {
  background: #fff;
}

.toolbar-actions {
  display: flex;
  gap: 0.45rem;
  padding: 0 0.8rem 0.75rem;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.79rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.8rem;
}

.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}

.inbox-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 0.68rem 0.78rem;
  cursor: pointer;
}

.inbox-item:hover {
  background: #eef5ff;
}

.inbox-item.active {
  background: #dcecff;
}

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.item-title {
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub {
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.79rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.method-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.08rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid #9db1cc;
  color: #27466d;
  background: #edf3fb;
}

.inbox-detail-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.7rem;
}

.request-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.request-header h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.protocol-badge {
  border-radius: 999px;
  border: 1px solid #9db1cc;
  color: #27466d;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.request-meta-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  padding: 0.65rem 0.75rem;
}

.request-meta-grid div {
  min-width: 0;
}

.request-meta-grid dt {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.request-meta-grid dd {
  margin: 0.12rem 0 0;
  font-size: 0.84rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-tabs {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.45rem;
}

.tab-link {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 0.32rem 0.62rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-link.active {
  background: #dcecff;
  border-color: #92b7e8;
}

.tab-panel {
  display: none;
  min-height: 320px;
}

.tab-panel-active {
  display: block;
}

.detail-box {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101b2a;
  color: #e4ecf6;
  min-height: 340px;
  max-height: calc(100vh - 420px);
  overflow: auto;
  padding: 0.8rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.panel-card {
  padding: 1rem;
}

.panel-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-subtitle {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.stack-form {
  max-width: 860px;
}

.stack-form .btn {
  margin-top: 0.9rem;
}

.files-shell {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.file-item:last-child {
  border-bottom: 0;
}

.file-meta {
  min-width: 0;
}

.file-name {
  font-weight: 700;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  color: var(--muted);
  font-size: 0.77rem;
}

.file-actions {
  display: flex;
  gap: 0.35rem;
}

.file-actions .btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  background: #1d2c3e;
  color: #f4f8ff;
  border-radius: 9px;
  padding: 0.5rem 0.75rem;
  font-size: 0.83rem;
}

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

@media (max-width: 920px) {
  .app-header {
    flex-wrap: wrap;
  }

  .inbox-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .inbox-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 340px;
  }

  .detail-box {
    max-height: 360px;
    min-height: 260px;
  }

  .request-meta-grid {
    grid-template-columns: 1fr;
  }
}
