/* Tardigrade ERP — styles mirroring the Figma design tokens (frontend spec §2). */
:root {
  --primary: #136F63; --primary-hover: #0F5A50; --accent: #2A7DE1;
  --bg-base: #F6F8F8; --surface: #FFFFFF; --border: #E2E7E7;
  --text-primary: #161A19; --text-secondary: #566160; --text-muted: #8A9492; --text-inverse: #FFFFFF;
  --success: #2E7D57; --warning: #C2850C; --danger: #B3261E; --info: #2F6FB3; --muted: #6B7674;
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg-base); color: var(--text-primary);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }

/* Top nav */
.topnav {
  height: 56px; background: var(--primary); color: var(--text-inverse);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topnav .brand { font-weight: 600; font-size: 16px; color: var(--text-inverse); }
.topnav .links { display: flex; align-items: center; gap: 24px; }
.topnav .links a { color: var(--text-inverse); opacity: 0.92; font-weight: 500; }
.topnav .avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.18);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.topnav .navleft { display: flex; align-items: center; gap: 28px; }
.topnav .navleft a { color: var(--text-inverse); text-decoration: none; }
.topnav .navleft .navlink { opacity: 0.92; font-weight: 500; font-size: 14px; }
/* Narrow windows: keep each label on one line (it wrapped one character per
   line), and let the links scroll sideways instead of squeezing. */
.topnav { gap: 16px; }
.topnav .navleft { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav .navleft::-webkit-scrollbar { display: none; }
.topnav .navleft a { white-space: nowrap; flex: none; }
@media (max-width: 640px) { .topnav { padding: 0 16px; } .topnav .navleft { gap: 16px; } }
.topnav .iconbtn { color: var(--text-inverse); background: transparent; border: none; cursor: pointer;
  display: inline-flex; align-items: center; position: relative; padding: 4px; }
.topnav .iconbtn:hover { opacity: 0.85; }
.topnav a.avatar { text-decoration: none; }
.topnav .badge-dot { position: absolute; top: -2px; right: -4px; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: 10px; line-height: 15px; min-width: 15px; height: 15px; padding: 0 4px;
  text-align: center; font-weight: 600; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: none; margin: 0; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--radius-md);
  font-weight: 500; font-size: 14px; border: 1px solid transparent; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--primary); color: var(--text-inverse); }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger); color: var(--text-inverse); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }
.card.tight { padding: 0; overflow: hidden; }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; }
.badge.success { background: #E5EFEA; color: var(--success); }
.badge.warning { background: #F8F0DC; color: var(--warning); }
.badge.danger  { background: #F4E0DE; color: var(--danger); }
.badge.info    { background: #E2EAF3; color: var(--info); }
.badge.muted   { background: #ECEEEE; color: var(--muted); }
.chip { font-family: var(--mono); }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-secondary);
  background: var(--bg-base); padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tr:last-child td { border-bottom: none; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.field input, .field select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); }
.field .errorlist { color: var(--danger); font-size: 12px; margin: 0; padding-left: 16px; }
.helptext { color: var(--text-muted); font-size: 12px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 12px; font-size: 13px; }
.alert.info { background: #E2EAF3; color: var(--info); }
.alert.success { background: #E5EFEA; color: var(--success); }
.alert.warning { background: #F8F0DC; color: var(--warning); }
.alert.danger { background: #F4E0DE; color: var(--text-secondary); }
.alert .title { font-weight: 600; color: var(--danger); display: block; margin-bottom: 2px; }

/* Drop zone */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface);
  padding: 32px; text-align: center; }
.dropzone.dragover { border-color: var(--primary); background: #F0F6F5; }
.filelist { list-style: none; padding: 0; margin: 12px 0 0; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--success); } .dot.bad { background: var(--danger); }

/* Auth card */
.auth-wrap { min-height: calc(100vh - 0px); display: flex; align-items: center; justify-content: center; }
.auth-card { width: 380px; max-width: 100%; word-break: keep-all; }

/* Log viewer */
.logview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 16px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; color: var(--text-secondary);
  max-height: 65vh; overflow: auto; }

.aging { color: var(--warning); font-size: 12px; font-weight: 500; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.tabs { display: flex; gap: 20px; margin: 8px 0 16px; }
.tabs a { color: var(--text-secondary); } .tabs a.active { color: var(--primary); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

/* Running app version, bottom-right — tells you what is actually deployed. */
.appver { position: fixed; right: 10px; bottom: 8px; font-size: 11px;
  color: var(--text-secondary); opacity: .55; pointer-events: none; z-index: 5; }

/* Loading state for slow form submits (e.g. 주문 가져오기): a spinner and a status line. */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
           animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Busy, not unavailable: keep the button solid while its request runs. */
.btn[aria-busy="true"], .btn[aria-busy="true"]:disabled { cursor: progress; opacity: 1; }
.btn-primary[aria-busy="true"] { background: var(--primary-hover); }
.loading-status { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 12px;
                  border-radius: var(--radius-sm); background: #E2EAF3; color: var(--info); font-size: 13px; }
.loading-status[hidden] { display: none; }   /* display:flex above would otherwise override [hidden] */
.loading-status small { display: block; color: var(--text-secondary); }
.loading-status .elapsed { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-right-color: currentColor; opacity: .6; } }
