/* =====================================================================
   파루씨앤씨 프레임워크 · 표준 프레임워크 관리자 UI
   common.css  —  Classic Enterprise ERP Style
   Design Tokens + Reset + 공통 컴포넌트
   (Buttons / Forms / Table-Form / Grid / Pagination / Modal)

   컨셉: SAP ERP / Oracle EBS /   계열
        High Information Density · Compact · Business First
   ===================================================================== */

/* Pretendard가 설치되어 있으면 사용하고, 런타임은 시스템 fallback만 사용한다. */

/* ------------------------------------------------------------------
   1. Design Tokens
   ------------------------------------------------------------------ */
:root {
  /* Core palette (ERP spec) */
  --c-primary: #2f69c2;         /* Primary Blue */
  --c-primary-dark: #24549e;
  --c-primary-tint: #eaf1fb;    /* very light blue (hover/selected) */
  --c-primary-tint-2: #dbe7f8;

  --c-header: #4e5665;          /* Header dark gray */
  --c-header-2: #3f4653;
  --c-sidebar: #f7f7f7;         /* Sidebar light gray */

  --c-bg: #ffffff;              /* Content background */
  --c-bg-alt: #fbfbfc;
  --c-border: #d6d6d6;          /* general border */
  --c-border-2: #e3e3e6;        /* soft inner border */

  --c-label: #f3f3f3;           /* form label bg */
  --c-label-border: #d5d5d5;    /* label border */
  --c-input-border: #cfcfcf;    /* input border */

  --c-text: #333333;
  --c-text-sub: #6b6f76;
  --c-text-mute: #8b9099;
  --c-text-invert: #ffffff;

  /* Grid */
  --c-grid-head: #4e5665;       /* dark gray header */
  --c-grid-head-2: #454c59;
  --c-grid-border: #d6d6d6;
  --c-grid-line: #e6e7ea;
  --c-row-hover: #eef4fc;       /* light blue hover */
  --c-row-selected: #d7e5fa;    /* blue selected */
  --c-row-stripe: #fbfcfd;
  --c-row-focus: #fdf6ec;       /* focused/edited row (peach) */

  /* State */
  --c-success: #2e8b57;
  --c-warning: #c9820a;
  --c-danger: #cc3b3b;
  --c-req: #e0352b;             /* required mark red */

  /* Radius (ERP: sharp) */
  --r: 2px;
  --r-0: 0px;

  /* Metrics */
  --h-input: 28px;
  --h-btn: 28px;
  --h-row: 28px;
  --h-grid-head: 30px;

  --header-h: 46px;
  --gnb-h: 40px;
  --sidebar-w: 210px;
  --tabbar-h: 32px;

  /* Typography */
  --font-sans: "Pretendard", "Malgun Gothic", "맑은 고딕", -apple-system,
    "Apple SD Gothic Neo", sans-serif;
  --fs-11: 11px;
  --fs-12: 12px;   /* grid / toolbar */
  --fs-13: 13px;   /* body / label / input */
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-18: 18px;

  --z-header: 100;
  --z-dropdown: 500;
  --z-modal: 1000;
  --z-toast: 1500;
}

/* ------------------------------------------------------------------
   2. Reset / Base
   ------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-13);
  line-height: 1.4;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  color: var(--c-text);
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Scrollbar (thin, business-like) */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-thumb {
  background: #c2c5cb;
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a9adb5;
  background-clip: content-box;
}
::-webkit-scrollbar-track {
  background: #f0f0f2;
}

.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;
}

/* ------------------------------------------------------------------
   3. Buttons (Height 28px · Radius 2px · Font 12~13px)
   ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: var(--h-btn);
  padding: 0 12px;
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 1;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r);
  background: #fff;
  color: var(--c-text);
  white-space: nowrap;
  transition: background-color 0.1s ease, border-color 0.1s ease;
  user-select: none;
}
.btn:focus-visible {
  outline: 1px solid var(--c-primary);
  outline-offset: 1px;
}
.btn .ico {
  width: 13px;
  height: 13px;
}

.btn-xs {
  height: 22px;
  padding: 0 8px;
  font-size: var(--fs-11);
}
.btn-sm {
  height: 24px;
  padding: 0 10px;
  font-size: var(--fs-12);
}
.btn-lg {
  height: 34px;
  padding: 0 18px;
  font-size: var(--fs-14);
}
.btn-block {
  width: 100%;
}

/* variants */
.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--c-text-invert);
}
.btn-primary:hover {
  background: var(--c-primary-dark);
  border-color: var(--c-primary-dark);
}

.btn-default {
  background: #f4f4f5;
  border-color: var(--c-input-border);
  color: var(--c-text);
}
.btn-default:hover {
  background: #e9e9ec;
}

.btn-dark {
  background: var(--c-header);
  border-color: var(--c-header);
  color: #fff;
}
.btn-dark:hover {
  background: var(--c-header-2);
}

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

.btn-success {
  background: var(--c-success);
  border-color: var(--c-success);
  color: #fff;
}
.btn-success:hover {
  background: #256f45;
}

/* utility (Excel / 동기화 / 자동생성 등 보조 액션) */
.btn-util {
  background: #eef1f5;
  border-color: #c4ccd6;
  color: #47505e;
}
.btn-util:hover {
  background: #e2e7ee;
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* icon-only tool button */
.btn-icon {
  width: var(--h-btn);
  height: var(--h-btn);
  padding: 0;
}

/* button bar */
.btn-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ------------------------------------------------------------------
   4. Standalone Form Controls (compact)
   ------------------------------------------------------------------ */
.form-control,
.form-select,
input[type="text"].ipt,
input[type="password"].ipt,
input[type="number"].ipt,
input[type="date"].ipt {
  width: 100%;
  height: var(--h-input);
  padding: 0 6px;
  font-size: var(--fs-13);
  font-family: inherit;
  color: var(--c-text);
  background: #fff;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r);
  transition: border-color 0.1s ease;
}
.form-control::placeholder {
  color: #a9adb5;
}
.form-control:focus,
.form-select:focus,
.ipt:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 1px rgba(47, 105, 194, 0.25);
}
.form-control:disabled,
.form-select:disabled,
.ipt:disabled,
.form-control[readonly] {
  background: #f1f1f3;
  color: var(--c-text-sub);
}
.form-control.is-invalid {
  border-color: var(--c-danger);
  background: #fff7f7;
}

textarea.form-control {
  height: auto;
  min-height: 56px;
  padding: 5px 6px;
  line-height: 1.4;
  resize: vertical;
}

/* select with caret */
.form-select {
  appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6f76' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
}

/* placeholder-like select (선택) */
.form-select.is-placeholder {
  color: #a9adb5;
}

/* compact in-grid controls (row height 28 → control 24) */
.form-control-sm,
.form-select-sm {
  height: 24px;
  padding: 0 5px;
  font-size: var(--fs-12);
}
.form-select-sm {
  appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6f76' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r);
  background-color: #fff;
  cursor: pointer;
  width: auto;
  min-width: 72px;
}

/* checkbox / radio (native look) */
.chk,
.rdo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-13);
  cursor: pointer;
  user-select: none;
}
.chk input,
.rdo input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--c-primary);
  cursor: pointer;
}

/* input addon group */
.input-group {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.input-group .form-control,
.input-group .form-select {
  flex: 1;
  min-width: 0;
}
.input-group .btn {
  flex: 0 0 auto;
}

/* small inline field label (standalone) */
.field-label {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--c-text);
}
.req {
  color: var(--c-req);
  font-weight: 700;
  margin-right: 2px;
}

/* ------------------------------------------------------------------
   5. Table-based Form (ERP Detail Form)
   Label(gray) + Input(white) rows · 2/4-column
   ------------------------------------------------------------------ */
table.form-tbl {
  width: 100%;
  table-layout: fixed;
  border-top: 1px solid var(--c-border);
  border-left: 1px solid var(--c-border);
}
table.form-tbl th,
table.form-tbl td {
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
/* label cell */
table.form-tbl th {
  background: var(--c-label);
  border-right: 1px solid var(--c-label-border);
  padding: 6px 10px;
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--c-text);
  text-align: left;
  white-space: nowrap;
}
table.form-tbl th .req {
  float: right;
}
/* value cell */
table.form-tbl td {
  background: #fff;
  padding: 4px 6px;
}
/* tighten controls inside form table */
table.form-tbl td .form-control,
table.form-tbl td .form-select,
table.form-tbl td .ipt {
  height: var(--h-input);
}
table.form-tbl td.pad {
  padding: 6px 8px;
}
/* label column widths */
.form-tbl col.lbl {
  width: 130px;
}
.form-tbl col.lbl-lg {
  width: 150px;
}

/* fieldset section title inside detail panel */
.form-sec-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  margin-top: 10px;
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--c-text);
  border-bottom: 2px solid var(--c-header);
}
.form-sec-title:first-child {
  margin-top: 0;
}

/* image / stamp placeholder box */
.img-box {
  width: 120px;
  height: 120px;
  border: 1px solid var(--c-input-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-mute);
  font-size: var(--fs-12);
  flex-direction: column;
  gap: 6px;
}
.img-box .ico {
  width: 34px;
  height: 34px;
  opacity: 0.55;
}

/* ------------------------------------------------------------------
   6. Panel (section wrapper with title bar)
   ------------------------------------------------------------------ */
.panel {
  border: 1px solid var(--c-border);
  background: #fff;
}
.panel + .panel {
  margin-top: 12px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  background: #fff;
  border-bottom: 2px solid var(--c-header);
}
.panel-head .p-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-14);
  font-weight: 700;
  color: var(--c-text);
}
.panel-head .p-title::before {
  content: "";
  width: 3px;
  height: 14px;
  background: var(--c-primary);
}
.panel-head .p-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.panel-body {
  padding: 10px;
}
.panel-body.no-pad {
  padding: 0;
}

/* ------------------------------------------------------------------
   7. Data Grid (Header dark gray · Row 28px)
   ------------------------------------------------------------------ */
.grid-wrap {
  border: 1px solid var(--c-grid-border);
  background: #fff;
  overflow: auto;
}

table.grid {
  width: 100%;
  font-size: var(--fs-12);
  table-layout: fixed;
}
table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: var(--h-grid-head);
  padding: 0 6px;
  font-weight: 700;
  font-size: var(--fs-12);
  color: #fff;
  text-align: center;
  background: var(--c-grid-head);
  border-right: 1px solid #5b6472;
  border-bottom: 1px solid #3b414c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid thead th:last-child {
  border-right: none;
}
table.grid tbody td {
  height: var(--h-row);
  padding: 0 6px;
  color: var(--c-text);
  background: #fff;
  border-right: 1px solid var(--c-grid-line);
  border-bottom: 1px solid var(--c-grid-line);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid tbody td:last-child {
  border-right: none;
}
table.grid tfoot td {
  height: var(--h-row);
  padding: 0 6px;
  background: #f3f3f3;
  border-top: 1px solid var(--c-grid-border);
  border-right: 1px solid var(--c-grid-line);
  font-weight: 700;
  vertical-align: middle;
}
table.grid tfoot td:last-child {
  border-right: none;
}
table.grid tbody tr:hover td {
  background: var(--c-row-hover);
}
table.grid tbody tr.is-selected td {
  background: var(--c-row-selected);
}
/* focused (edited) row - peach tint like reference */
table.grid tbody tr.is-focus td {
  background: var(--c-row-focus);
}

/* alignment helpers */
.grid .ta-l { text-align: left; }
.grid .ta-c { text-align: center; }
.grid .ta-r { text-align: right; }

/* tree cell (hierarchy rows inside a grid) */
table.grid td.tree-cell {
  text-align: left;
  white-space: nowrap;
}
table.grid td.tree-cell .tw {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
table.grid td.tree-cell .t-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid var(--c-input-border);
  background: #fff;
  color: var(--c-text-sub);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  flex: 0 0 14px;
}
table.grid td.tree-cell .t-toggle.is-leaf {
  border-color: transparent;
  background: transparent;
  cursor: default;
}
table.grid td.tree-cell .t-ico {
  width: 13px;
  height: 13px;
  color: var(--c-primary);
  flex: 0 0 13px;
}
.tree-indent { display: inline-block; }
.tree-indent.d1 { width: 16px; }
.tree-indent.d2 { width: 32px; }
.tree-indent.d3 { width: 48px; }
.tree-indent.d4 { width: 64px; }

/* grid sub-title (small caption above a grid) */
.grid-caption {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.grid-caption .gc-title {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--c-text);
}
.grid-caption .gc-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 12px;
  background: var(--c-primary);
  margin-right: 5px;
  vertical-align: -1px;
}
.grid-caption .gc-count {
  font-size: var(--fs-12);
  color: var(--c-text-sub);
}
.grid-caption .gc-count b { color: var(--c-primary); }
.grid-caption .gc-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

/* stat box (summary tile) */
.stat-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-primary);
}
.stat-box .s-label {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--c-text-sub);
}
.stat-box .s-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -0.02em;
}

/* link cell */
table.grid td a {
  color: var(--c-primary);
  font-weight: 600;
}

/* row-number & checkbox & handle columns */
table.grid th.col-no,
table.grid td.col-no {
  width: 42px;
  text-align: center;
  color: var(--c-text-sub);
}
table.grid th.col-chk,
table.grid td.col-chk {
  width: 34px;
  text-align: center;
}
table.grid th.col-handle,
table.grid td.col-handle {
  width: 26px;
  text-align: center;
  color: var(--c-text-mute);
  background: #fafafa;
}
table.grid td.col-handle .arr {
  color: var(--c-primary);
  font-weight: 700;
}

/* editable-cell (grid inline edit) */
table.grid td.cell-edit {
  padding: 0;
  background: #fff;
}
table.grid td.cell-edit input,
table.grid td.cell-edit select {
  width: 100%;
  height: 100%;
  min-height: 26px;
  border: 1px solid transparent;
  background: transparent;
  padding: 0 6px;
  font-size: var(--fs-12);
  font-family: inherit;
  color: var(--c-text);
}
table.grid td.cell-edit input:focus,
table.grid td.cell-edit select:focus {
  outline: none;
  border-color: var(--c-primary);
  background: #fff;
}
/* active editing cell (white box like reference) */
table.grid td.cell-active {
  box-shadow: inset 0 0 0 2px var(--c-primary);
  background: #fff;
}

/* required mark inside grid cell */
.cell-req::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid var(--c-req);
  border-right: 5px solid transparent;
  margin-right: 3px;
  vertical-align: top;
}

/* checkmark for boolean column */
.grid .use-y {
  color: var(--c-primary);
  font-weight: 700;
}

/* empty state */
.grid-empty td {
  height: 120px !important;
  text-align: center;
  color: var(--c-text-mute);
  background: #fff !important;
}

/* ------------------------------------------------------------------
   8. Grid Toolbar (Results + action buttons + icon tools)
   ------------------------------------------------------------------ */
.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}
.grid-toolbar .results {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--c-text-sub);
}
.grid-toolbar .results b {
  color: var(--c-primary);
}
.grid-toolbar .tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.grid-toolbar .icon-tools {
  display: flex;
  gap: 2px;
  margin-right: 4px;
}
.tool {
  width: 24px;
  height: 24px;
  border: 1px solid var(--c-input-border);
  background: #fff;
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-sub);
}
.tool:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}
.tool .ico {
  width: 14px;
  height: 14px;
}

/* ------------------------------------------------------------------
   9. Search / Filter Area (compact inline)
   ------------------------------------------------------------------ */
.search-bar {
  border: 1px solid var(--c-border);
  background: var(--c-bg-alt);
  padding: 8px 10px;
}
table.search-tbl {
  width: 100%;
  table-layout: fixed;
}
table.search-tbl th {
  background: var(--c-label);
  border: 1px solid var(--c-label-border);
  padding: 5px 10px;
  font-size: var(--fs-13);
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  width: 120px;
}
table.search-tbl td {
  border: 1px solid var(--c-border-2);
  background: #fff;
  padding: 4px 6px;
}
.search-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
}

/* inline single-row filter (label + control) */
.filter-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--c-border);
}
.filter-inline .fi-label {
  background: var(--c-label);
  border-right: 1px solid var(--c-label-border);
  padding: 0 10px;
  height: 30px;
  display: flex;
  align-items: center;
  font-size: var(--fs-13);
  font-weight: 700;
  white-space: nowrap;
}
.filter-inline .fi-ctrl {
  padding: 3px 6px;
  display: flex;
  align-items: center;
}

/* ------------------------------------------------------------------
   10. Pagination
   ------------------------------------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 8px;
}
.pagination .pg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  font-size: var(--fs-12);
  border: 1px solid var(--c-input-border);
  background: #fff;
  color: var(--c-text-sub);
}
.pagination .pg:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
  text-decoration: none;
}
.pagination .pg.is-active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
  font-weight: 700;
}
.pagination .pg.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   11. Badges (minimal)
   ------------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-size: var(--fs-11);
  font-weight: 700;
  border-radius: var(--r);
  border: 1px solid transparent;
}
.badge-blue {
  background: var(--c-primary-tint);
  color: var(--c-primary-dark);
  border-color: #bcd2f0;
}
.badge-green {
  background: #e7f4ec;
  color: var(--c-success);
  border-color: #bfe2cd;
}
.badge-red {
  background: #fdeaea;
  color: var(--c-danger);
  border-color: #f3c9c9;
}
.badge-gray {
  background: #eff0f2;
  color: var(--c-text-sub);
  border-color: #dcdee2;
}
.badge-amber {
  background: #fdf3e3;
  color: #a5680a;
  border-color: #efd9ac;
}

/* ------------------------------------------------------------------
   11-1. Wide Log Grid helpers (many columns · horizontal scroll)
   ------------------------------------------------------------------ */
.grid-scroll {
  border: 1px solid var(--c-grid-border);
  background: #fff;
  overflow: auto;         /* 가로 스크롤 허용 */
}
.grid-scroll table.grid {
  table-layout: auto;     /* 컬럼 수가 많은 로그성 그리드는 내용 기준 */
  width: max-content;
  min-width: 100%;
}
.grid-scroll table.grid thead th,
.grid-scroll table.grid tbody td {
  white-space: nowrap;
}
/* 긴 문자열 셀: 최대폭 + 말줄임 (title 속성으로 전체값 tooltip) */
td.cell-clip {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td.cell-clip.w-sm { max-width: 140px; }
td.cell-clip.w-lg { max-width: 360px; }
/* HTTP status / 상태 코드용 mono 숫자 */
.mono { font-family: "D2Coding","Consolas","Menlo",monospace; }

/* ------------------------------------------------------------------
   12. Modal
   ------------------------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 34, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}
.modal-backdrop.is-open {
  display: flex;
}
.modal {
  width: 560px;
  max-width: calc(100vw - 60px);
  max-height: calc(100vh - 80px);
  background: #fff;
  border: 1px solid #b8bcc4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.modal-lg {
  width: 860px;
}
.modal.modal-sm {
  width: 380px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 12px;
  background: var(--c-header);
  color: #fff;
}
.modal-head h3 {
  font-size: var(--fs-14);
  color: #fff;
  font-weight: 700;
}
.modal-close {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.modal-body {
  padding: 14px;
  overflow: auto;
}
.modal-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: center;
  gap: 6px;
  background: #f7f7f8;
}

/* ------------------------------------------------------------------
   13. Utilities
   ------------------------------------------------------------------ */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-top: 0; margin-bottom: 8px; }
.w-full { width: 100%; }
.text-sub { color: var(--c-text-sub); }
.text-danger { color: var(--c-danger); }
.text-primary { color: var(--c-primary); }
.text-c { text-align: center; }
.text-r { text-align: right; }
.fs-12 { font-size: var(--fs-12); }
.fs-13 { font-size: var(--fs-13); }
.fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------
   14. Generic Split Layouts (reusable grid columns)
   ------------------------------------------------------------------ */
.split-even {          /* 좌 grid + 우 grid (동일 비율) */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}
.split-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: start;
}
.split-4060 {            /* Master(좌 ~40%) ↔ Mapping(우 ~60%) */
  display: grid;
  grid-template-columns: 40fr 60fr;
  gap: 12px;
  align-items: start;
}
.split-3763 {            /* 부서(좌 ~37%) ↔ 권한(우 ~63%) */
  display: grid;
  grid-template-columns: 37fr 63fr;
  gap: 12px;
  align-items: start;
}
.stack {               /* 상단/하단 세로 적층 */
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.col-min { min-width: 0; }   /* grid child overflow guard */

@media (max-width: 1100px) {
  .split-even,
  .split-3 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------
   15. Content Tabs (in-page tabs for detail panels)
   ------------------------------------------------------------------ */
.tabs .tab-nav {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--c-header);
}
.tabs .tab-nav .t {
  height: 30px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--c-text-sub);
  background: #eef0f2;
  border: 1px solid var(--c-border);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  user-select: none;
  margin-bottom: -2px;
}
.tabs .tab-nav .t:hover { color: var(--c-text); }
.tabs .tab-nav .t.is-active {
  color: var(--c-primary);
  background: #fff;
  border-color: var(--c-header);
  border-bottom: 2px solid #fff;
}
.tabs .tab-panel { display: none; padding: 12px 0; }
.tabs .tab-panel.is-active { display: block; }

/* ------------------------------------------------------------------
   16. Layer Popup (modeless / draggable window)
   ------------------------------------------------------------------ */
.layer-dim {
  position: fixed;
  inset: 0;
  background: rgba(30, 34, 42, 0.35);
  display: none;
  z-index: var(--z-modal);
}
.layer-dim.is-open { display: block; }

.layer {
  position: fixed;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  width: 640px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 1px solid #9aa0aa;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.3);
  display: none;
  flex-direction: column;
  z-index: calc(var(--z-modal) + 1);
}
.layer.is-open { display: flex; }
.layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 10px 0 12px;
  background: var(--c-header);
  color: #fff;
  cursor: move;
  user-select: none;
}
.layer-head h3 {
  font-size: var(--fs-14);
  color: #fff;
  font-weight: 700;
}
.layer-head .layer-tools { display: flex; gap: 2px; }
.layer-head .lbtn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border-radius: var(--r);
}
.layer-head .lbtn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.layer-body {
  padding: 12px;
  overflow: auto;
  max-height: 62vh;
}
.layer-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: center;
  gap: 6px;
  background: #f7f7f8;
}

/* ------------------------------------------------------------------
   17. Alert / Confirm Dialog (system message box)
   ------------------------------------------------------------------ */
.dlg-dim {
  position: fixed;
  inset: 0;
  background: rgba(30, 34, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-toast);
}
.dlg-dim.is-open { display: flex; }
.dlg {
  width: 380px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 1px solid #b8bcc4;
  border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.dlg-head {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: var(--fs-14);
  font-weight: 700;
  color: #fff;
  background: var(--c-header);
}
.dlg-body {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 18px 16px;
  font-size: var(--fs-13);
  line-height: 1.5;
  color: var(--c-text);
}
.dlg-ico {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
}
.dlg-ico.info { color: var(--c-primary); }
.dlg-ico.warn { color: var(--c-warning); }
.dlg-ico.error { color: var(--c-danger); }
.dlg-ico.success { color: var(--c-success); }
.dlg-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: center;
  gap: 6px;
  background: #f7f7f8;
}

/* ------------------------------------------------------------------
   18. Extra Input Components (gallery)
   ------------------------------------------------------------------ */
/* toggle switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 42px;
  height: 22px;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px;
  height: 22px;
  background: #c3c7ce;
  border-radius: 22px;
  transition: background 0.15s ease;
}
.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--c-primary); }
.switch input:checked ~ .thumb { transform: translateX(20px); }

/* segmented radio group */
.seg {
  display: inline-flex;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r);
  overflow: hidden;
}
.seg label {
  position: relative;
  padding: 0 12px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--c-text-sub);
  background: #fff;
  border-right: 1px solid var(--c-input-border);
  cursor: pointer;
}
.seg label:last-child { border-right: none; }
.seg input { position: absolute; opacity: 0; }
.seg input:checked + span { color: #fff; }
.seg label:has(input:checked) { background: var(--c-primary); color: #fff; }

/* search input with leading icon */
.search-input {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}
.search-input .ico {
  position: absolute;
  left: 7px;
  width: 15px;
  height: 15px;
  color: var(--c-text-mute);
  pointer-events: none;
}
.search-input .form-control { padding-left: 27px; }

/* number stepper */
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r);
  overflow: hidden;
  height: var(--h-input);
}
.stepper button {
  width: 26px;
  border: none;
  background: #f1f1f3;
  color: var(--c-text);
  font-size: 15px;
  line-height: 1;
}
.stepper button:hover { background: #e4e4e8; }
.stepper input {
  width: 52px;
  border: none;
  border-left: 1px solid var(--c-input-border);
  border-right: 1px solid var(--c-input-border);
  text-align: center;
  font-family: inherit;
  font-size: var(--fs-13);
}
.stepper input:focus { outline: none; }

/* date range */
.date-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.date-range .tilde { color: var(--c-text-mute); }

/* required / helper text under field */
.help-text {
  font-size: var(--fs-11);
  color: var(--c-text-mute);
  margin-top: 3px;
}
.help-text.error { color: var(--c-danger); }

/* spec table (component doc row) */
.spec-tbl { width: 100%; }
.spec-tbl th,
.spec-tbl td {
  border: 1px solid var(--c-border);
  padding: 8px 10px;
  font-size: var(--fs-13);
  text-align: left;
  vertical-align: middle;
}
.spec-tbl thead th {
  background: var(--c-label);
  font-weight: 700;
}
.spec-tbl td.demo { background: #fff; }
.spec-tbl th.rowlbl {
  background: var(--c-label);
  width: 160px;
  font-weight: 700;
}
.spec-tbl code,
code.snip {
  font-family: "D2Coding", "Consolas", "Menlo", monospace;
  font-size: var(--fs-12);
  background: #f2f4f7;
  border: 1px solid #e2e5ea;
  border-radius: var(--r);
  padding: 1px 5px;
  color: #35507a;
}
/* demo swatch row for gallery */
.demo-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
