:root {
  --bg: #0B1220;
  --panel: #0E1729;
  --panel-alt: #0B1526;
  --header-bg: #0A1526;
  --border: #1B2740;
  --border-soft: #182338;
  --text: #E7ECF3;
  --text-dim: #8CA0C2;
  --text-faint: #6E7D99;
  --text-faint2: #5E6E8C;
  --input-bg: #0E1729;
  --input-border: #263349;
  --accent-gold: #E8A33D;
  --price-bg: rgba(232,163,61,0.10);
  --price-text: #F3C878;
  --danger: #E8817A;
  --green: #1E8E3E;
  --thead-bg: #152238;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #28344A; border-radius: 4px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.login-logo-wrap {
  background: #FFFFFF;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  margin-bottom: 18px;
}
.login-logo { height: 34px; width: auto; display: block; }
.login-heading { margin: 0 0 20px; font-size: 18px; font-weight: 700; color: var(--text); }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#login-form input:focus { border-color: #4E8FD6; }
.login-btn {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gold);
  color: #12243D;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.login-btn:hover { filter: brightness(1.05); }
.error-msg { color: var(--danger); font-size: 13px; margin: 4px 0 0; }

/* ---------- App shell ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}
.header-logo-wrap {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  margin-right: 16px;
}
.header-logo { height: 28px; width: auto; display: block; }
.header-title { flex: 1; }
.header-title h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: 0.3px; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.whoami { font-size: 12px; color: var(--text-dim); margin-right: 4px; }
.upload-status { font-size: 12px; color: var(--text-faint); min-width: 60px; }

.btn-primary {
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--text);
  border: 1px solid #2C3C58;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-primary:hover { border-color: #3E5478; }
.btn-green { background: var(--accent-gold); color: #12243D; border: none; }
.btn-green:hover { filter: brightness(1.05); }
.header-btn { padding: 8px 16px; }

.body-wrap { display: flex; min-height: calc(100vh - 68px); }

.category-nav {
  flex: 0 0 268px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.nav-search { padding: 16px 18px 10px; }
.nav-search input {
  width: 100%;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.category-list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.cat-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 9px 10px;
  margin-bottom: 2px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  background: transparent;
  color: #A9B7CE;
  font-weight: 500;
}
.cat-row.active { background: rgba(78,143,214,0.16); color: #EAF3FF; font-weight: 700; }
.cat-dot { width: 6px; height: 6px; border-radius: 50%; background: #2A3854; flex: 0 0 auto; }
.cat-dot.has-items { background: #3FAE6E; }
.cat-label { flex: 1; }
.cat-count { font-size: 11px; color: var(--text-faint); }

.main-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.toolbar {
  padding: 18px 28px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.toolbar-title h2 { margin: 0; font-size: 20px; font-weight: 700; color: #F2F5FA; }
p.cat-count.toolbar-count { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#search-box {
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  width: 200px;
}

.drawing-panel {
  margin: 0 28px 14px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.drawing-panel img { max-width: 100%; max-height: 210px; object-fit: contain; display: block; }

.table-scroll { flex: 1; overflow: auto; padding: 0 28px 24px; }
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.items-table thead th {
  text-align: center;
  padding: 10px 12px;
  font-weight: 700;
  color: #9DAEC8;
  background: var(--thead-bg);
  border-bottom: 1px solid #223351;
}
.th-sub { font-weight: 500; color: var(--text-faint2); }
.items-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.items-table tbody tr:nth-child(even) { background: var(--panel-alt); }
.col-no { width: 40px; color: var(--text-faint); }
.col-del { width: 46px; text-align: center; }

.cell-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 12.5px;
  padding: 6px 8px;
  border: 1px solid var(--input-border);
  border-radius: 5px;
  color: var(--text);
  outline: none;
  background: var(--input-bg);
  font-family: inherit;
}
.cell-input::placeholder { color: #5A6A85; }
.cell-input:focus { border-color: #4E8FD6; }
.cell-input.model-input { font-family: 'SF Mono', Consolas, monospace; font-weight: 600; color: #F2F5FA; }

.price-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 12.5px;
  padding: 6px 8px;
  border: 1px dashed var(--accent-gold);
  border-radius: 5px;
  color: var(--price-text);
  outline: none;
  background: var(--price-bg);
  font-family: inherit;
  text-align: right;
  font-weight: 600;
}
.price-input:focus { border-style: solid; }

input[type="date"].cell-input { color-scheme: dark; }

.row-del-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

@media (max-width: 900px) {
  .body-wrap { flex-direction: column; }
  .category-nav { flex: none; width: 100%; max-height: 200px; }
}
