/* web_admin UI - stylesheet v2 (2026-11-04)
   Kept selectors: every class name the pages actually use (22) + the layers built by JS.
   Presentational attributes (width/height/align/bgcolor/border*) are neutralised by CSS here. */

/* 1. tokens - dark is the default; light is available with body.light */
:root {
  --bg: #161a21;
  --panel: #1d222b;
  --ink: #e6e9ef;
  --muted: #a4adb9;
  --line: #343b46;
  --accent: #4bb987;
  --accent-ink: #10231a;
  --accent-soft: #213039;
  --danger: #ff8f85;
  --warn: #e4c671;
  --radius: 10px;
  --sp1: 6px;
  --sp2: 10px;
  --sp3: 16px;
  --sp4: 24px;
  --sidebar: 240px;
  --row-alt: #212630;
  --button: #2a313c;
  --button-2: #2f3742;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --font: "Malgun Gothic", "Apple SD Gothic Neo", "NanumGothic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;   /* native controls, scrollbars and autofill follow the dark theme */
}

body.light {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1c2230;
  --muted: #5b6573;
  --line: #d6dae1;
  --accent: #0b7a4b;
  --accent-ink: #ffffff;
  --accent-soft: #e7f2ec;
  --danger: #b3261e;
  --warn: #8a6d0b;
  --row-alt: #f7f9fb;
  --button: #eef1f4;
  --button-2: #dfe4ea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* 2. base */
body {
  margin: 0;
  padding: var(--sp3) var(--sp3) var(--sp4);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
}

/* the sidebar gutter applies only when the page renders the nav (the login page has none) */
body:has(nav.topnav) { padding-left: calc(var(--sidebar) + var(--sp3)); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p, ul, ol { line-height: 1.6; margin: 8px 0; }
b { color: var(--ink); }
img { max-width: 100%; }

/* scrollbar colour follows the theme (the light default looked white against the dark page) */
html { scrollbar-color: var(--line) var(--bg); }
table[width="900"], table[width="800"] { scrollbar-color: var(--line) var(--panel); }

/* 3. nav - left sidebar, no visible scrollbar in it (compact so the menu usually fits the viewport).
   On phone width it becomes a top bar (see section 9). */
nav.topnav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: var(--sidebar);
  height: 100vh;
  padding: 12px 10px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;          /* IE/Edge */
}

nav.topnav::-webkit-scrollbar { display: none; }

nav.topnav .brand {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: var(--sp2);
  color: var(--ink);
}

nav.topnav .menu {
  display: block;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav.topnav .menu > li { margin-bottom: 1px; }

nav.topnav .menu > li > a {
  display: block;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
}

nav.topnav .menu > li > a:hover { background: var(--accent-soft); text-decoration: none; }

/* submenus are listed inline under their group (no pop-up in a sidebar) */
nav.topnav .submenu {
  display: block;
  padding: 0 0 6px 12px;
  margin: 0;
  list-style: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

nav.topnav .submenu a {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: normal;
}

nav.topnav .submenu a:hover { background: var(--accent-soft); color: var(--ink); text-decoration: none; }

nav.topnav .signout { margin-top: var(--sp2); border-top: 1px solid var(--line); padding-top: var(--sp2); }
nav.topnav .signout a { color: var(--danger); display: block; }

/* 4. panels and tables */
table { border-collapse: collapse; }

table[width="900"], table[width="800"], table[width="100%"] {
  width: 100%;
  max-width: 1120px;
  border: 0;
}

table.bbs_property, table.table_form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp1);
}

td, th {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  padding: 6px 8px;
  border: 0;
  vertical-align: middle;
}

th { font-weight: 700; background: var(--accent-soft); text-align: left; }

/* legacy pages mark the header row with class="txt_black" on td cells */
tr.txt_black td, td.txt_black { font-weight: 700; }

/* zebra rows for data lists */
tbody tr:nth-child(even) { background: var(--row-alt); }

/* row hover is CSS-owned: the pages used inline onMouseOver/onMouseOut that set light colours
   (cream on hover, #FFFFFF on mouse-out, which stayed white in dark mode) */
tbody tr:hover { background: var(--accent-soft); }
tr[onclick] { cursor: pointer; }

/* flagged row (mem_delList marks f_testFlag='Y' rows) - theme neutral */
.flagged { background: var(--accent-soft); }

/* presentational <hr> used by old pages */
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* text helpers kept for existing markup */
.txt_9, .fnt-9pt { font-size: 12.5px; }
.txt_pro { font-size: 14px; }
.txt_16 { font-size: 16px; font-weight: 700; }
.txt_point { color: var(--danger); font-size: 14px; }
.copy { color: var(--muted); font-size: 12.5px; }
.num { font-size: 14px; padding-right: 12px; font-variant-numeric: tabular-nums; }
/* status text colors — conn.asp helpers return plain text, so presentation is CSS only */
.st_accent { color: var(--accent); }
.st_warn { color: var(--warn); }
.st_red { color: var(--danger); }

.dot_line, .line { border-bottom: 1px solid var(--line); padding: 6px 0; }
.two_line {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--row-alt);
  padding: 8px 10px;
  border-radius: 8px;
}
.dot_linefnt { font-weight: 700; color: #31425f; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* 5. forms and buttons */
.searchbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }

input[type="text"], input[type="password"], select, textarea {
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(11, 122, 75, .25);
  outline-offset: 1px;
  border-color: var(--accent);
}

.form_basic { width: 200px; }
.form_basic2 { width: auto; }
/* date field: measured with value "2026-11-04" the content needs 93px (scrollWidth) and the
   previous inline width was 80px, so the last two digits were cut off. 110px = 93 + padding. */
.form_date { width: 110px; }
[class="808080_input"], select[class="808080_input"] { width: auto; }
/* textarea is a content area, not a single-line field. .form_basic gives single-line inputs a fixed
   200px width - measured: board/qna_write.asp textarea with cols="90" rendered 198px inside an 818px
   cell. Textareas fill their container and grow with the content. */
textarea, textarea.TxtBox, textarea.form_basic {
  width: 100%;
  min-height: 240px;
  field-sizing: content; /* auto-grow to the typed content; ignored where unsupported */
}

input[type="button"], input[type="submit"], button {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button);
  color: var(--ink);
  cursor: pointer;
}

/* pages carry inline background-colour hints; normalise them so buttons look consistent */
input[class="form_basic2"] { background: var(--button) !important; color: var(--ink) !important; }

input[type="button"]:hover, input[type="submit"]:hover, button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.clButtonCmd {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  min-height: 34px;
  padding: 8px 14px;
}

.clButtonCmd:hover { filter: brightness(.94); color: var(--accent-ink); }

.CmdButton {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.bt_btn_out, .bt_btn_click {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--button);
  cursor: pointer;
}

.bt_btn_click { background: var(--button-2); font-weight: 700; }
.bt_btn_over { background: var(--accent-soft); }

.hand { cursor: pointer; }
.heading { font-weight: 700; }
.border { border: 1px solid var(--line); }

/* editor toolbar: make the old fixed-cell toolbar wrap instead of stretching to width="25" */
table.table_form td { padding: 4px 6px; }
table.table_form td[width="25"], table.table_form td[width="10"] { width: auto; }
table.table_form input[type="button"] { font-size: 12.5px; padding: 6px 10px; white-space: nowrap; }

/* editor area - theme aware (a hard-coded white made the edit area look like a hole in dark mode).
   The 720px cap was removed: measured, the editor row was 1134px wide but the box rendered 302px
   because the row is a <tr> shown as display:block - the cell shrink-wrapped to the iframe's attribute
   width. The board pages now use display:table-row for those rows (see the sector rows) so the box
   fills the available width. */
iframe[name="KnEditor"], iframe[name="preview"] {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* layers built by KNEditor.js */
.kn-layer {
  position: absolute;
  display: none;
  z-index: 40;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
}

.kn-panel p { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.kn-panel input[type="text"] { margin-bottom: 6px; }

.kn-swatch-row { display: flex; gap: 2px; }
.kn-swatch-cell {
  display: block;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.kn-swatch-cell:hover { outline: 2px solid var(--accent); }

.clButtonCmd.kn-pressed,
input[type="button"].kn-pressed { border-color: var(--accent); color: var(--accent); }
.clButtonCmd.kn-pressed-down,
input[type="button"].kn-pressed-down { transform: translateY(1px); }

/* layers built by Calendar.js */
.kn-calendar {
  position: absolute;
  z-index: 40;
  min-width: 240px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}

.kn-cal-head { font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.kn-cal-nav {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  padding: 3px 7px;
  color: var(--muted);
}
.kn-cal-nav:hover { border-color: var(--accent); color: var(--accent); }

.kn-cal-grid { display: grid; grid-template-columns: repeat(7, 30px); gap: 4px; }
.kn-cal-dow { font-size: 11.5px; color: var(--muted); text-align: center; }
.kn-cal-blank { height: 28px; }

.kn-cal-day {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--row-alt);
}
.kn-cal-day:hover { border-color: var(--accent); color: var(--accent); }
.kn-cal-day.kn-cal-today { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }

/* 6. login */
main.login-card {
  max-width: 420px;
  margin: 40px auto;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

main.login-card h1 { margin: 0 0 14px; font-size: 18px; }
main.login-card label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13px; color: var(--muted); }
main.login-card input[type="text"], main.login-card input[type="password"] { width: 100%; }
main.login-card input[type="submit"] { margin-top: 14px; width: 100%; min-height: 42px; }

/* 7. pagination + misc */
.pager { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pager a { padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }

/* 8. accessibility */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--sp3); top: var(--sp2); background: var(--panel); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
[aria-live] { color: var(--danger); }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* 9. phone */
@media (max-width: 720px) {
  body { font-size: 15px; padding: 0 var(--sp2) var(--sp3); }
  body:has(nav.topnav) { padding-left: var(--sp2); }

  nav.topnav {
    position: static;
    width: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    margin: 0 calc(var(--sp2) * -1) var(--sp2);
    padding: 10px var(--sp2);
  }
  nav.topnav .brand { font-size: 16px; margin-bottom: var(--sp1); }
  nav.topnav .menu { display: flex; flex-wrap: wrap; gap: 6px 8px; }
  nav.topnav .menu > li > a { padding: 8px 10px; }

  /* on a phone the submenu is listed inline - hover pop-ups cannot be opened by touch */
  nav.topnav .submenu {
    position: static;
    display: block;
    min-width: 0;
    padding: 4px 0 8px 12px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  nav.topnav .submenu a { white-space: normal; color: var(--muted); font-weight: 400; }
  nav.topnav .signout { margin: var(--sp1) 0 0; border-top: 0; padding-top: 0; }

  table[width="900"], table[width="800"] {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* data tables marked class="rows" become stacked cards (needs data-label on cells) */
  table.rows { display: block; width: 100%; max-width: 100%; }
  table.rows thead { display: none; }
  table.rows tr {
    display: block;
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
  table.rows td { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border: 0; }
  table.rows td::before { content: attr(data-label); color: var(--muted); font-weight: 700; }
  table.rows td:empty { display: none; }

  /* label/value tables (two cells per row) already read well when stacked */
  table.kv tr { display: flex; gap: 10px; align-items: baseline; padding: 6px 8px; }
  table.kv td:first-child { color: var(--muted); font-weight: 700; min-width: 96px; }

  .form_basic, .form_basic2, input[type="text"], input[type="password"], select, textarea.TxtBox {
    width: 100%;
    max-width: 100%;
  }
  /* inside a block-level scrollable table, width:100% resolves against the table's intrinsic
     (wide) width - cap controls to the viewport so the search row does not overflow */
  input[type="text"], input[type="password"], select { max-width: calc(100vw - 40px); }
  input[type="button"], input[type="submit"], button, .clButtonCmd { min-height: 44px; }
  td, th { word-break: break-word; }
  iframe[name="KnEditor"], iframe[name="preview"] { min-height: 220px; }
  .kn-layer, .kn-calendar { max-width: calc(100vw - 20px); }
  .kn-cal-grid { grid-template-columns: repeat(7, 34px); }
  .pager { gap: 8px; }
}

/* 10. theme: dark is the default (section 1). Light look = class="light" on <body>.
   Chrome-first: IE11 is not supported (no CSS custom properties), so no IE fallback block is kept. */

/* 11. print */
@media print {
  nav.topnav, .pager, input[type="button"], input[type="submit"] { display: none !important; }
  body { background: #fff; color: #000; padding: 0; font-size: 12px; }
  table.bbs_property, table.table_form { box-shadow: none; border-color: #999; }
}
