* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f7f7f8;
  color: #1f2328;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: #6b7280; }
.small { font-size: 12px; }
.pad { padding: 16px; }

/* Top bar */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e4e8;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 600; font-size: 15px; }

.flash {
  background: #eef6ee;
  border-bottom: 1px solid #cfe8cf;
  color: #2f5f32;
  padding: 8px 20px;
  font-size: 13px;
}

/* Layout: three columns */
.app {
  display: flex;
  max-width: 1100px;
  margin: 20px auto;
  min-height: 560px;
  background: #ffffff;
  border: 1px solid #e2e4e8;
  border-radius: 6px;
  overflow: hidden;
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.col-stocks { width: 190px; border-right: 1px solid #e2e4e8; flex-shrink: 0; }
.col-files { width: 230px; border-right: 1px solid #e2e4e8; flex-shrink: 0; }
.col-lines { flex: 1; }

.col-head {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e4e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Lists */
.list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}

.list-item {
  display: block;
  padding: 8px 10px;
  border-radius: 4px;
  color: #1f2328;
  text-decoration: none;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item:hover { background: #f1f2f4; }
.list-item.active { background: #eaf0fe; color: #1a56db; font-weight: 600; }

/* Inline create / upload forms */
.inline-create, .upload-form {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e4e8;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inline-create { flex-direction: row; }
.inline-create input[type="text"] { flex: 1; min-width: 0; }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  text-align: center;
  padding: 24px;
}

/* Editor */
.editor-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  min-height: 0;
}

.editor {
  flex: 1;
  min-height: 300px;
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid #d0d3d9;
  border-radius: 4px;
  padding: 10px 12px;
  color: #1f2328;
  background: #fff;
}
.editor:focus { outline: none; border-color: #1a56db; }

.editor-bar { display: flex; justify-content: flex-end; }

/* Inputs & buttons */
input[type="text"], input[type="password"], input[type="file"] {
  font-family: inherit;
  font-size: 13.5px;
  border: 1px solid #d0d3d9;
  border-radius: 4px;
  padding: 7px 9px;
  color: #1f2328;
  background: #fff;
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: #1a56db;
}

.btn {
  background: #fff;
  border: 1px solid #d0d3d9;
  color: #1f2328;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn:hover { background: #f4f5f6; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.disabled { color: #c2c6cc; cursor: default; }
.btn.disabled:hover { background: #fff; }

.btn-primary {
  background: #1a56db;
  border-color: #1a56db;
  color: #fff;
}
.btn-primary:hover { background: #164cc2; }

.icon-btn {
  background: none;
  border: none;
  color: #1a56db;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.link-btn {
  background: none;
  border: none;
  color: #1a56db;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: #c62828; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border: 1px solid #e2e4e8;
  border-radius: 6px;
  padding: 28px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { font-size: 17px; margin: 0 0 4px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: #444a53;
}
.login-card .error { color: #c62828; font-size: 13px; margin: 0; }

@media (max-width: 760px) {
  .app { flex-direction: column; margin: 0; border-radius: 0; min-height: 100vh; }
  .col-stocks, .col-files { width: auto; border-right: none; border-bottom: 1px solid #e2e4e8; max-height: 200px; }
}

/* Documentation page */
.docs {
  max-width: 800px;
  margin: 24px auto;
  padding: 24px 28px;
  background: #ffffff;
  border: 1px solid #e2e4e8;
  border-radius: 6px;
}
.docs h1 { font-size: 22px; margin: 0 0 6px; }
.docs h2 { font-size: 17px; margin: 28px 0 10px; border-bottom: 1px solid #eef0f3; padding-bottom: 6px; }
.docs h3 { font-size: 14.5px; margin: 18px 0 6px; }
.docs p { margin: 8px 0; line-height: 1.55; }
.docs ul { margin: 8px 0; padding-left: 22px; line-height: 1.6; }
.docs code { background: #f3f4f6; border-radius: 3px; padding: 1px 5px; font-size: 12.5px; }

.doc-code {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  margin: 10px 0;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.doc-table th, .doc-table td {
  text-align: left;
  border: 1px solid #e2e4e8;
  padding: 7px 10px;
  vertical-align: top;
}
.doc-table th { background: #f7f8fa; font-weight: 600; }

/* API keys page */
.keys-wrap {
  max-width: 920px;
  margin: 24px auto;
  padding: 24px 28px;
  background: #ffffff;
  border: 1px solid #e2e4e8;
  border-radius: 6px;
}
.keys-wrap h1 { font-size: 22px; margin: 0 0 6px; }
.keys-wrap p { margin: 8px 0; line-height: 1.55; }
.keys-wrap code { background: #f3f4f6; border-radius: 3px; padding: 1px 5px; font-size: 12.5px; }

.new-key {
  background: #eef6ee;
  border: 1px solid #cfe8cf;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 14px 0;
}
.new-key-label { margin: 0 0 8px !important; color: #2f5f32; font-size: 13px; }

.key-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.key-line code {
  background: #f3f4f6;
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 12.5px;
  word-break: break-all;
  white-space: nowrap;
}

.create-key {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}
.create-key input[type="text"] { flex: 1; min-width: 0; }