/* PuccioTech Control — tema scuro professionale */
:root {
  --bg: #0e1116;
  --bg-raised: #151a22;
  --bg-input: #0b0e13;
  --border: #242c38;
  --border-strong: #32405a;
  --text: #e7eaf0;
  --text-muted: #8b94a5;
  --accent: #2563eb;
  --accent-hover: #3b76f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--text-muted); }
small { font-size: 12px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-raised); border-right: 1px solid var(--border);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.main { flex: 1; padding: 28px 32px 60px; max-width: 1280px; min-width: 0; }
.main-public { max-width: none; display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.brand-center { justify-content: center; margin-bottom: 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--accent);
  color: #fff; font-weight: 700; font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-name { font-weight: 700; line-height: 1.1; font-size: 15px; }
.brand-name small { color: var(--text-muted); font-weight: 500; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--text-muted); font-weight: 500;
}
.sidebar nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); text-decoration: none; }
.sidebar nav a.active { color: var(--text); background: rgba(37, 99, 235, 0.16); }
.sidebar-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar-user { color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards & grids */
.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.card-narrow { max-width: 680px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-alert { border-color: rgba(239, 68, 68, 0.5); }
.kpi-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 700; }
.kpi-dim { color: var(--text-muted); font-size: 18px; font-weight: 500; }
.kpi-sub { color: var(--text-muted); font-size: 12px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; color: var(--text-muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-strong);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions { position: relative; }
.td-actions form.inline { display: inline-block; }
.nowrap { white-space: nowrap; }

/* Badges & dots */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.badge-warn { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-neutral { background: rgba(37, 99, 235, 0.15); color: #7aa5f8; }
.badge-muted { background: rgba(139, 148, 165, 0.14); color: var(--text-muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 6px; }
.dot-ok { background: var(--ok); box-shadow: 0 0 6px rgba(34, 197, 94, 0.7); }
.dot-off { background: var(--text-muted); opacity: 0.5; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 9px 11px; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}
input:disabled { opacity: 0.55; }
textarea { resize: vertical; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; }
.check input { width: auto; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; }
.fieldset legend { padding: 0 8px; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type="search"] { max-width: 320px; }
.toolbar select { width: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 9px 16px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  background: transparent; color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn-warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); }
.btn-warn:hover { background: rgba(245, 158, 11, 0.25); }
.btn-danger { background: rgba(239, 68, 68, 0.14); color: #f87171; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* Flash */
.flash {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px;
  border: 1px solid; font-weight: 500;
}
.flash-success { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.4); color: #4ade80; }
.flash-error { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.4); color: #f87171; }
.flash-warn { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.4); color: #fbbf24; }

/* Auth */
.auth-card {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 14px;
  padding: 34px; width: 100%; max-width: 400px; margin: 20px;
}
.auth-card h1 { font-size: 20px; margin-bottom: 14px; }

/* Dashboard lists */
.attention-list, .event-list, .plain-list { list-style: none; margin: 0; padding: 0; }
.attention { border-left: 3px solid var(--border-strong); margin-bottom: 8px; border-radius: 4px; }
.attention a { display: block; padding: 8px 12px; color: var(--text); }
.attention a:hover { background: rgba(255, 255, 255, 0.03); text-decoration: none; }
.attention strong { display: block; font-size: 14px; }
.attention .muted { font-size: 12px; }
.attention-high { border-left-color: var(--danger); }
.attention-medium { border-left-color: var(--warn); }
.event-list li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.event-list li:last-child { border-bottom: none; }
.event-time { color: var(--text-muted); white-space: nowrap; font-size: 12px; padding-top: 1px; }
.plain-list li { padding: 3px 0; }

/* Detail lists */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.dl dt { color: var(--text-muted); font-size: 13px; }
.dl dd { margin: 0; font-size: 14px; }

/* Details/accordion */
.details { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.details summary { cursor: pointer; color: var(--accent-hover); font-weight: 600; font-size: 14px; }
.details > form { margin-top: 12px; }
.row-details { display: inline-block; position: relative; }
.row-details summary { list-style: none; display: inline-flex; }
.row-details summary::-webkit-details-marker { display: none; }
.row-details .popform {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px; min-width: 260px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); text-align: left;
}

/* Utility */
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.mt { margin-top: 22px; }
.inline { display: inline; }
.pager { display: flex; gap: 10px; margin-top: 14px; }

/* Responsive */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row;
    align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px;
  }
  .brand { margin-bottom: 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { padding: 6px 10px; font-size: 13px; }
  .sidebar-foot { margin-top: 0; margin-left: auto; border-top: none; padding-top: 0; }
  .main { padding: 18px 16px 50px; }
  .row-2 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
