:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dde1e6;
  --text: #1c2330;
  --muted: #6b7280;
  --accent: #2f5fdc;
  --accent-hover: #24499e;
  --danger: #c8362c;
  --danger-hover: #a02921;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.shell-header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.shell-header nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
}
.link-btn:hover { text-decoration: underline; }

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

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

.page-header h1 { margin: 0; font-size: 20px; }

input[type="text"], input[type="date"], input[type="number"], input[type="password"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: #f0f1f3; }

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

.search-row { margin-bottom: 16px; }
.search-row input { max-width: 320px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0;
}
.pagination .btn-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.pagination .btn-secondary:disabled:hover { background: #fff; }
.pagination span { color: var(--muted); font-size: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfc; }

.muted { color: var(--muted); }
.empty-state { padding: 40px 0; text-align: center; color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.form-actions .spacer { flex: 1; }

.error-banner {
  background: #fdecea;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.login-wrap {
  max-width: 360px;
  margin: 80px auto;
}
.login-wrap h1 { text-align: center; margin-bottom: 24px; }
.login-wrap .field { margin-bottom: 14px; }
.login-wrap .btn { width: 100%; }

.attachments-section { margin-top: 32px; }
.attachments-section h2 { font-size: 15px; margin-bottom: 12px; }

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.attachment-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  width: 140px;
  text-align: center;
  font-size: 12px;
}
.attachment-card img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 6px;
  display: block;
  background: #f0f1f3;
}
.attachment-card .file-icon {
  width: 100%;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  margin-bottom: 6px;
  background: #f0f1f3;
  color: var(--muted);
  font-size: 24px;
}
.attachment-card .name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
}
.attachment-card .remove-btn {
  font-size: 11px;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.view-value {
  padding: 8px 0 4px;
  min-height: 20px;
  word-break: break-word;
}

.attachment-card .thumb-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}
.lightbox[hidden] {
  display: none;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  font-size: 32px;
  line-height: 1;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2330;
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1100;
}
.toast[hidden] {
  display: none;
}
.toast.success {
  background: #1e7e34;
}
