/* app/static/css/style.css | v3.0.0-alpha.2.1 */
:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #dfe4e8;
  --bg: #e5e9ec;
  --surface: #f8fafb;
  --surface-2: #eef2f5;
  --border: #cbd3da;
  --text: #17202a;
  --muted: #67737d;
  --nav: #263442;
  --nav-hover: #35485a;
  --top: #18222d;
  --accent: #d95d20;
  --accent-dark: #b94d18;
  --success: #257a4a;
  --warning: #a96800;
  --danger: #a53131;
  --shadow: 0 2px 10px rgba(0, 0, 0, .07);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: #174f7b; }
code, .mono-small { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mono-small { font-size: 12px; word-break: break-all; }
.center { text-align: center; }

.topbar {
  height: 64px; background: var(--top); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.14);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand img, .login-brand img { height: 42px; width: auto; background: #273545; border-radius: 7px; padding: 4px; }
.brand strong, .login-brand strong { font-size: 24px; }
.version { font-size: 12px; opacity: .68; }
.userbox { display: flex; align-items: center; gap: 14px; }
.userbox form { margin: 0; }

.app-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { background: var(--nav); padding: 18px 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar a { color: #eef3f7; text-decoration: none; padding: 11px 12px; border-radius: 8px; white-space: nowrap; }
.sidebar a:hover { background: var(--nav-hover); }
.content { padding: 24px; min-width: 0; overflow: auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
h1 { margin: 0 0 4px; font-size: clamp(25px, 3vw, 34px); }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 20px 0 10px; }
.lead { margin: 0; color: #53616d; }
.muted { color: var(--muted); font-size: 14px; }
.back-link { display: inline-block; margin-bottom: 8px; text-decoration: none; font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 16px 0; }
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.card { padding: 20px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; color: inherit; }
a.card:hover { transform: translateY(-1px); border-color: #aeb9c2; }
.card strong { font-size: 23px; }
.metric-cards .card strong { font-size: 30px; }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.panel { padding: 18px; margin: 16px 0; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.action-panel { border-left: 4px solid var(--accent); }
.danger-zone { border-left: 4px solid var(--warning); }
.narrow { max-width: 600px; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.two-column .panel { margin: 0; }

.table-wrap { overflow: auto; width: 100%; }
.table-wrap.compact { max-height: 280px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #d7dde2; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .035em; color: #52606b; background: #f1f4f6; position: sticky; top: 0; z-index: 1; }
tr:hover td { background: rgba(255,255,255,.45); }

.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 650; background: #e3e8ec; color: #24313c; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.subtle { background: #344657; color: white; }
.btn.warning { background: #f4c86d; color: #422e00; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.badge, .status-pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 8px; background: #e1e6ea; color: #33414c; font-size: 12px; font-weight: 700; }
.badge.ok { background: #d6eddf; color: #195c36; }
.muted-badge { opacity: .65; }
.status-pill { background: #dce8f2; color: #204c70; padding: 7px 11px; }
.head-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.grid-form .span-2 { grid-column: span 2; }
.stack-form { display: grid; gap: 14px; }
.inline-form { display: flex; gap: 9px; flex-wrap: wrap; align-items: end; }
.inline-form > input, .inline-form > select { min-width: 150px; flex: 1; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 650; }
input, select, textarea {
  font: inherit; padding: 10px; border: 1px solid #aeb9c2; border-radius: 8px; background: #fff; color: var(--text); min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(217,93,32,.24); border-color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: 9px; padding: 12px; }
legend { font-weight: 700; padding: 0 6px; }
.check-grid, .permission-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.check { flex-direction: row; align-items: center; font-weight: 500; }
.check input { width: auto; }
.permission-grid { margin: 12px 0 18px; }
.permission-item { flex-direction: row; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border); padding: 10px; border-radius: 8px; font-weight: 500; }
.permission-item input { width: auto; margin-top: 4px; }
.permission-item span { display: grid; gap: 3px; }
.permission-item code { font-size: 11px; color: var(--muted); }
.form-note { background: #edf2f5; border-radius: 8px; padding: 10px; color: #56636d; font-size: 13px; }

.tabs { display: flex; gap: 6px; overflow: auto; border-bottom: 1px solid #b9c3cb; margin-bottom: 14px; }
.tabs a { text-decoration: none; padding: 10px 13px; border-radius: 8px 8px 0 0; color: #43515c; white-space: nowrap; }
.tabs a.active { background: var(--surface); border: 1px solid #b9c3cb; border-bottom-color: var(--surface); margin-bottom: -1px; font-weight: 700; color: #17202a; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 14px 0; }
.summary-grid > div, .time-grid > div { background: rgba(248,250,251,.78); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: grid; gap: 5px; }
.summary-grid small, .time-grid small { color: var(--muted); }
.time-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-top: 16px; }
.request-text { white-space: pre-wrap; line-height: 1.55; }
.linked-object { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 4px; }

.tree-indent { display: inline-block; width: calc(var(--depth) * 24px); }
.asset-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.child-card { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; text-decoration: none; background: var(--surface-2); color: inherit; }
.child-card small { color: var(--muted); }
.editor { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.editor > summary, details > summary { cursor: pointer; font-weight: 700; color: #345468; margin-bottom: 10px; }

.meter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.meter-card { border: 1px solid var(--border); background: #f3f6f8; border-radius: 10px; padding: 14px; min-width: 0; }
.meter-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.meter-head > div { display: grid; gap: 3px; }
.meter-head small { color: var(--muted); }
.meter-value { font-size: 20px; font-weight: 800; white-space: nowrap; }
.forecast { display: grid; gap: 3px; background: #e8f0f5; border-radius: 8px; padding: 9px; margin: 8px 0; font-size: 13px; }

.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; border-left: 2px solid #c3ccd3; padding: 5px 0 14px 16px; display: grid; gap: 3px; }
.timeline-item::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: absolute; left: -5px; top: 10px; }
.timeline-item span { color: var(--muted); font-size: 12px; }
.timeline-item p { margin: 3px 0 0; }

.chat-list { display: grid; gap: 10px; margin-bottom: 14px; }
.chat-message { border: 1px solid var(--border); border-radius: 9px; padding: 11px; background: #f2f5f7; }
.chat-message > div { display: flex; justify-content: space-between; gap: 8px; }
.chat-message time { color: var(--muted); font-size: 12px; }
.chat-message p { margin: 8px 0 0; white-space: pre-wrap; }
.notification { padding: 10px 0; border-bottom: 1px solid #d7dde2; }
.notification small { display: block; color: var(--muted); margin-top: 4px; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 12px; }
.flash { padding: 10px 12px; border-radius: 8px; border: 1px solid transparent; }
.flash.danger { background: #f8d7da; border-color: #efb5bb; color: #74232b; }
.flash.success { background: #d1e7dd; border-color: #add6c4; color: #185a39; }
.flash.warning { background: #fff0c7; border-color: #ead38d; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #cfd6dc; }
.login-card { width: min(420px, 100%); background: #f5f7f8; border: 1px solid #b8c1c9; border-radius: 14px; padding: 28px; box-shadow: 0 14px 40px rgba(0,0,0,.15); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.login-card form { display: grid; gap: 14px; }

@media (max-width: 900px) {
  .two-column { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 12px; }
  .version { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; position: sticky; top: 64px; z-index: 30; padding: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.1); }
  .sidebar a { padding: 9px 10px; }
  .content { padding: 14px; }
  .userbox > span { display: none; }
  .page-head { align-items: stretch; flex-direction: column; }
  .head-badges { justify-content: flex-start; }
  .meter-grid { grid-template-columns: 1fr; }
  .inline-form { display: grid; grid-template-columns: 1fr; }
  .inline-form > input, .inline-form > select { width: 100%; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr; }
  .brand strong { font-size: 20px; }
  .brand img { height: 36px; }
}
