/* --------------------------------------------------------------------------
   Internal Postman — design tokens (Postman-like, no external font CDN)
   Fonts: system stack for crisp UI on macOS / Windows / Linux
   -------------------------------------------------------------------------- */

:root {
  /* Typography — Inter-like feel via system fonts */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;

  --line-tight: 1.25;
  --line-normal: 1.5;

  /* Surfaces */
  --bg-app: #f5f5f5;
  --bg-header: #1c1c1c;
  --bg-sidebar: #fafafa;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f0f0f0;

  /* Borders */
  --border-subtle: #e8e8e8;
  --border-default: #d4d4d4;
  --border-focus: #ff6c37;

  /* Text */
  --text-primary: #212121;
  --text-secondary: #6b6b6b;
  --text-muted: #8e8e8e;
  --text-on-dark: #f5f5f5;

  /* Accent (Postman orange) */
  --accent: #ff6c37;
  --accent-hover: #e85d2e;
  --accent-muted: rgba(255, 108, 55, 0.12);

  /* Status */
  --error: #c62828;
  --success: #2e7d32;

  --radius-sm: 4px;
  --radius-md: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
  --header-h: 52px;
  --sidebar-w: 260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-normal);
  color: var(--text-primary);
  background: var(--bg-app);
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 1.25rem;
  background: var(--bg-header);
  color: var(--text-on-dark);
  border-bottom: 1px solid #000;
  box-shadow: var(--shadow-sm);
}

.app-header__brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.app-header__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--line-tight);
}

.app-header__badge {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Layout ---------- */
#content {
  display: flex;
  height: calc(100vh - var(--header-h));
  min-height: 0;
}

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  padding: 1rem 0.875rem;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}

#main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

/* ---------- Sidebar ---------- */
#user-info {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

#user-status {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--line-tight);
  word-break: break-word;
}

.sidebar-divider {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--border-subtle);
}

#admin-panel h3 {
  margin: 0 0 0.5rem;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

#users-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#users-list li {
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding: 0.5rem 0.625rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
}

/* ---------- Main / sections ---------- */
.section-title {
  margin: 0 0 1rem;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.section-sub {
  margin: 0 0 1.25rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 42rem;
  line-height: var(--line-normal);
}

.section-sub code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}

.auth-block {
  margin-bottom: 2rem;
}

.auth-block + .auth-block {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

#app-placeholder {
  max-width: 40rem;
}

#app-placeholder h2 {
  margin-top: 0;
  font-size: var(--text-xl);
  font-weight: 600;
}

#app-placeholder p {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

/* ---------- Forms ---------- */
form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  max-width: 22rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

input[type="text"],
input[type="password"],
input[type="email"] {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: var(--text-muted);
}

input:hover {
  border-color: #bbb;
}

input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* ---------- Buttons ---------- */
button {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary,
form button[type="submit"] {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover,
form button[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary,
#logout-btn,
#refresh-users-btn {
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-secondary:hover,
#logout-btn:hover,
#refresh-users-btn:hover {
  background: var(--bg-hover);
  border-color: #c0c0c0;
}

#refresh-users-btn {
  width: 100%;
  margin-bottom: 0.25rem;
}

/* ---------- Phase 1 workspace ---------- */
#main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.workspace-root {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--bg-card);
}

.workspace-sidebar {
  width: 280px;
  min-width: 260px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  overflow: hidden;
}

.ws-env-bar,
.ws-collections-head {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.ws-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ws-env-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.ws-select {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  font-size: var(--text-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.ws-collections-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.collections-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.col-item {
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: var(--text-sm);
  border-left: 3px solid transparent;
}

.col-item:hover {
  background: var(--bg-hover);
}

.col-active {
  background: var(--accent-muted);
  border-left-color: var(--accent);
}

.col-name {
  font-weight: 500;
}

.col-meta {
  float: right;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.req-sublist {
  padding: 0.15rem 0 0.35rem 0.75rem;
}

.req-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  margin: 1px 0;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
}

.req-item:hover {
  background: var(--bg-hover);
}

.req-active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.workspace-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.request-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.method-select {
  width: 5.5rem;
  padding: 0.45rem 0.35rem;
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.req-url-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.65rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

.req-name-input {
  margin: 0 1rem 0.5rem;
  max-width: 24rem;
  padding: 0.35rem 0.5rem;
  font-size: var(--text-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.req-tabs,
.resp-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.req-tabs button,
.resp-tabs button {
  padding: 0.45rem 0.75rem;
  font-size: var(--text-sm);
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: -1px;
}

.req-tabs button.tab-active,
.resp-tabs button.tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panels {
  flex: 0 0 auto;
  max-height: 38vh;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.tab-panel {
  min-height: 4rem;
}

.body-editor {
  width: 100%;
  min-height: 120px;
  margin-top: 0.5rem;
  padding: 0.65rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.auth-panel {
  margin-top: 0.75rem;
}

.auth-panel label {
  display: block;
  margin-bottom: 0.5rem;
}

.wide-input {
  width: 100%;
  max-width: 32rem;
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.kv-table th {
  text-align: left;
  padding: 0.35rem 0.5rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
}

.kv-table td {
  padding: 0.25rem 0.35rem;
  vertical-align: middle;
}

.kv-table input[type="text"] {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.kv-on {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.kv-add-host {
  margin-top: 0.5rem;
}

.col-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.response-panel {
  border-top: 1px solid var(--border-subtle);
  flex: 1;
  min-height: 140px;
  max-height: 42vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1e1e1e;
  color: #d4d4d4;
}

.response-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.45rem 1rem;
  background: #252526;
  border-bottom: 1px solid #333;
}

.response-toolbar .resp-tabs {
  margin-left: auto;
  border: none;
  padding: 0;
}

.response-toolbar .resp-tabs button {
  color: #aaa;
}

.response-toolbar .resp-tabs button.tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.resp-status {
  font-weight: 700;
  font-size: var(--text-sm);
}

.resp-status.ok {
  color: #6abf69;
}

.resp-status.warn {
  color: #e6c07b;
}

.resp-status.err {
  color: #f48771;
}

.resp-time,
.resp-meta-extra {
  font-size: var(--text-xs);
  color: #888;
}

.resp-pre {
  flex: 1;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-panel {
  border-top: 1px solid var(--border-subtle);
  max-height: 22vh;
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  background: var(--bg-app);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-xs);
}

.history-list li {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.history-list li:hover {
  background: var(--bg-hover);
}

.hist-method {
  font-weight: 600;
  color: var(--accent);
  margin-right: 0.35rem;
}

.hint {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}

.hint code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.1em 0.3em;
  background: var(--bg-hover);
  border-radius: 3px;
}

.btn-sm {
  padding: 0.3rem 0.5rem;
  font-size: var(--text-xs);
}

.btn-icon {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.btn-icon:hover {
  color: var(--text-primary);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-box {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-head h3 {
  margin: 0;
  font-size: var(--text-lg);
}

.modal-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* ---------- Utilities ---------- */
.hidden {
  display: none !important;
}

.message {
  margin-top: 0.5rem;
  font-size: var(--text-sm);
  color: var(--success);
}

.message.error {
  color: var(--error);
}
