/* Keystone Arch — one stylesheet. Palette: Oracle Redwood (calm, muted, colour only for meaning). */
:root {
  --bark: #312D2A; --red: #C74634; --sunrise: #FACD62; --ember: #AE562C; --fog: #94AFAF;
  --ivy: #759C6C; --sand: #E5DBBE; --ocean: #2C5967; --surf: #41817E; --forest: #2B6242;
  --air: #FCFBFA; --pebble: #8B8580; --granite: #67605B;
  --bg: #F5F3F0; --card: #FFFFFF; --line: #E4DFDA; --line2: #D3CCC5; --tint: #F4EFE3;
  --ocean-tint: #E6EEF0; --red-tint: #F8E7E4; --ivy-tint: #EAF1E8; --sun-tint: #FDF3D6;
  --text: var(--bark); --muted: var(--granite); --soft: var(--pebble);
  --radius: 10px; --shadow: 0 1px 2px rgba(49,45,42,.06), 0 2px 8px rgba(49,45,42,.05);
  --side: 236px; --top: 56px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--surf); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); background: var(--bark); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 16px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ember); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand small { font-weight: 500; opacity: .7; font-size: 13px; }
.topbar .spacer { flex: 1; }
.top-btn { position: relative; background: none; border: 0; color: #fff; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.top-btn:hover { background: rgba(255,255,255,.1); }
.badge { position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--sunrise); color: var(--bark); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surf); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 22px; }
.user-btn:hover { background: rgba(255,255,255,.1); }
.user-btn span { font-size: 14px; font-weight: 600; }

/* ---------- side menu (PC) ---------- */
.side { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); background: var(--card); border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; z-index: 20; }
.nav-group { font-size: 11px; font-weight: 700; color: var(--soft); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14px; min-height: 44px; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--ocean); color: #fff; }
.nav a .count { margin-left: auto; background: var(--sunrise); color: var(--bark); font-size: 11px; border-radius: 9px; padding: 1px 7px; }
.nav a.on .count { background: #fff; }

/* ---------- bottom tabs (phone) ---------- */
.tabsbar { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: var(--card); border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tabsbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--granite); font-size: 11px; font-weight: 600; position: relative; }
.tabsbar a.on { color: var(--ocean); }
.tabsbar a:hover { text-decoration: none; }
.tabsbar .badge { top: 4px; right: calc(50% - 22px); }

/* ---------- main ---------- */
.main { margin-left: var(--side); padding: calc(var(--top) + 24px) 28px 48px; max-width: calc(1180px + var(--side)); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.crumbs { font-size: 13px; color: var(--soft); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--surf); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line2); background: var(--card); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--ocean); border-color: var(--ocean); color: #fff; }
.btn.primary:hover { background: #244b57; }
.btn.danger { color: var(--red); border-color: #e6c3bd; }
.btn.danger:hover { background: var(--red-tint); }
.btn.good { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .icon { width: 18px; height: 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 8px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--granite); }
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- tiles (Setup) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); color: var(--text); min-height: 84px; }
.tile:hover { border-color: var(--fog); text-decoration: none; box-shadow: var(--shadow); }
.tile .ti { width: 40px; height: 40px; border-radius: 10px; background: var(--ocean-tint); color: var(--ocean); display: grid; place-items: center; flex: none; }
.tile b { display: block; font-size: 15px; }
.tile span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--granite); text-transform: uppercase; letter-spacing: .07em; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }

/* ---------- tables / lists ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { flex: 1; min-width: 180px; position: relative; }
.search input { width: 100%; padding-left: 40px; }
.search .icon { position: absolute; left: 12px; top: 12px; color: var(--soft); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 700; color: var(--granite); text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--air); }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: var(--air); }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: var(--fog); margin-bottom: 8px; }
.muted { color: var(--muted); }
.soft { color: var(--soft); font-size: 13px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--granite); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ivy-tint); color: var(--forest); border-color: #cfe0ca; }
.chip.off { background: var(--bg); color: var(--soft); }
.chip.warn { background: var(--sun-tint); color: #7a5a00; border-color: #f1dfa6; }
.chip.bad { background: var(--red-tint); color: var(--red); border-color: #eccdc7; }
.chip.info { background: var(--ocean-tint); color: var(--ocean); border-color: #cbdadf; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .lbl { font-size: 13px; font-weight: 700; color: var(--text); }
.field .req { color: var(--red); }
.field .help { font-size: 12px; color: var(--soft); }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: 8px; background: #fff; outline: none; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--surf); box-shadow: 0 0 0 3px rgba(65,129,126,.15); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; user-select: none; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--line2); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--ivy); }
.switch input:checked::after { left: 21px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 8px; cursor: pointer; min-height: 44px; background: #fff; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ocean); margin: 0; }
.check:has(input:checked) { border-color: var(--ocean); background: var(--ocean-tint); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { width: 48px; height: 44px; border: 1px solid var(--line2); border-radius: 8px; display: grid; place-items: center; cursor: pointer; font-weight: 600; font-size: 13px; background: #fff; }
.days input { display: none; }
.days label:has(input:checked) { background: var(--ocean); color: #fff; border-color: var(--ocean); }
.form-foot { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--air); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.form-foot .grow { flex: 1; }
.meta { font-size: 12px; color: var(--soft); }

.suggest { font-size: 12px; color: var(--ocean); background: var(--ocean-tint); padding: 2px 8px; border-radius: 10px; }

/* ---------- my day ---------- */
.hello { display: flex; gap: 16px; align-items: center; padding: 22px 22px; background: linear-gradient(0deg, var(--card), var(--card)); }
.hello h1 { font-size: 24px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; color: var(--text); }
.stat:hover { text-decoration: none; background: var(--air); }
.stat .si { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--ocean-tint); color: var(--ocean); }
.stat .si.sun { background: var(--sun-tint); color: #8a6400; }
.stat .si.ivy { background: var(--ivy-tint); color: var(--forest); }
.stat b { font-size: 24px; display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed li.unread { background: #FBF8F0; }
.feed .fi { width: 34px; height: 34px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; flex: none; color: var(--granite); }
.feed .fi .icon { width: 18px; height: 18px; }
.feed .ft { flex: 1; min-width: 0; }
.feed .ft b { display: block; font-size: 14px; }
.feed .ft p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.feed time { font-size: 12px; color: var(--soft); white-space: nowrap; }

.setting .ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 340px; }
/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 14px; font-weight: 600; font-size: 14px; color: var(--granite); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; min-height: 44px; }
.tabs button.on { color: var(--ocean); border-bottom-color: var(--ocean); }

/* ---------- modal + toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(49,45,42,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100% - 32px)); }
.toast { background: var(--bark); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); display: flex; gap: 10px; align-items: center; }
.toast.bad { background: var(--red); }
.toast.ok .icon { color: #b9d9b1; }
.menu-pop { position: fixed; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.14); z-index: 70; min-width: 220px; padding: 6px; }
.menu-pop button, .menu-pop a { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 14px; min-height: 44px; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--bg); text-decoration: none; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- history ---------- */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; }
.hist .who { font-weight: 700; font-size: 14px; }
.hist .when { color: var(--soft); font-size: 12px; margin-left: 6px; }
.hist .chg { margin-top: 6px; font-size: 13px; display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; }
.hist .chg .k { color: var(--granite); }
.hist del { color: var(--red); }
.hist ins { color: var(--forest); text-decoration: none; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bark); }
.auth-card { width: min(420px, 100%); background: var(--card); border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card .brand { color: var(--bark); margin-bottom: 22px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.auth-card .btn { width: 100%; margin-top: 14px; }
.auth-foot { text-align: center; color: rgba(255,255,255,.55); font-size: 12px; margin-top: 18px; }
.notice { padding: 12px 14px; border-radius: 8px; font-size: 14px; background: var(--ocean-tint); color: var(--ocean); }
.notice.bad { background: var(--red-tint); color: var(--red); }
.notice.ok { background: var(--ivy-tint); color: var(--forest); }
.notice.warn { background: var(--sun-tint); color: #6d5000; }

.loading { padding: 60px; text-align: center; color: var(--soft); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--surf); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .side { display: none; }
  .tabsbar { display: flex; }
  .main { margin-left: 0; padding: calc(var(--top) + 16px) 16px calc(84px + env(safe-area-inset-bottom)); }
  .user-btn > span:not(.avatar), .brand small, .hide-phone { display: none; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  table.list.cards thead { display: none; }
  table.list.cards, table.list.cards tbody, table.list.cards tr, table.list.cards td { display: block; width: 100%; }
  table.list.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.list.cards td { padding: 2px 0; border: 0; }
  table.list.cards td:first-child { font-weight: 700; font-size: 15px; }
  table.list.cards td[data-l]:not(:first-child)::before { content: attr(data-l) ": "; color: var(--soft); font-size: 12px; }
  table.list.cards td.num { text-align: left; }
  .hist .chg { grid-template-columns: 1fr; }
  .page-head .btn { flex: 1; }
  .form-foot .btn { flex: 1; }
  h1 { font-size: 20px; }
  .feed li.setting { flex-wrap: wrap; }
  .setting .ft { flex-basis: 100%; }
  .setting .ctl { max-width: none; width: 100%; justify-content: flex-start; padding-left: 0; }
}
@media print { .topbar, .side, .tabsbar { display: none; } .main { margin: 0; padding: 0; } }
