/* FelisHome — gestionale (lato host). Identità "costa al mattino". */

:root {
  --bg: #F2F7FA;
  --surface: #FFFFFF;
  --ink: #1C3542;
  --ink2: #54717F;
  --line: #DCE9F1;
  --mare: #2478A0;
  --mare-strong: #175D80;
  --cielo: #BFE0F0;
  --cielo-soft: #EAF5FB;
  --side: #173D52;
  --side-hi: #1F4E67;
  --ok: #2E8763;  --ok-bg: #E4F3EC;
  --warn: #A85A2E; --warn-bg: #FDF3E4;
  --danger: #B23A3A; --danger-bg: #F8E7E7;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
a { color: var(--mare); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- struttura pagina ---------- */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }

.side {
  background: var(--side);
  color: #C8DDE9;
  display: flex;
  flex-direction: column;
  padding: 18px 0 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .logo {
  font-family: Georgia, serif;
  font-size: 20px; color: #fff;
  padding: 0 20px 16px;
}
.side .logo span { color: #7CC1E0; }
.side nav { display: flex; flex-direction: column; }
.side nav a {
  color: #C8DDE9; padding: 8px 20px; font-size: 13px;
  border-left: 3px solid transparent;
}
.side nav a:hover { background: var(--side-hi); color: #fff; text-decoration: none; }
.side nav a.on { background: var(--side-hi); color: #fff; border-left-color: #7CC1E0; }
.side nav .sep { border-top: 1px solid #24506A; margin: 8px 20px; }
.side .sidefoot { margin-top: auto; padding: 14px 20px 16px; font-size: 11px; color: #7FA2B5; }

.main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: 20px 26px; flex: 1; }

/* ---------- barra superiore ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px 26px;
}
.struct-select select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%232478A0' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1.5px solid var(--mare); color: var(--mare-strong);
  font-weight: 600; font-size: 14px;
  border-radius: 9px; padding: 8px 34px 8px 12px; cursor: pointer;
}
.topbar .date { font-size: 12px; color: var(--ink2); margin-left: auto; }
.topbar .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--mare); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- piè di pagina legale ---------- */
.legal-footer {
  background: var(--side); color: #9DBECE;
  font-size: 11px; line-height: 1.7;
  text-align: center; padding: 10px 22px;
}
.legal-footer strong { color: #CFE4EF; font-weight: 600; }

/* ---------- componenti ---------- */
h1.page { font-family: Georgia, serif; font-weight: 400; font-size: 24px; color: var(--mare-strong); margin: 0 0 4px; }
.page-sub { color: var(--ink2); font-size: 13px; margin: 0 0 18px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px; font-size: 12px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink2); font-weight: 600;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 15px;
}
.stat b { display: block; font-size: 24px; color: var(--side); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink2); }
.stat .up { color: var(--ok); font-size: 11px; font-weight: 600; }
.stat .todo { color: var(--warn); font-size: 11px; font-weight: 600; }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink2); font-weight: 600; padding: 8px 8px; border-bottom: 2px solid var(--line);
}
table.list td { padding: 9px 8px; border-bottom: 1px solid #EDF3F8; vertical-align: middle; }
table.list tr:hover td { background: #F8FBFD; }
.num { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 10px; border-radius: 99px; white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--cielo-soft); color: var(--mare); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }

.ota {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 5px; color: #fff;
}

.btn {
  display: inline-block; background: var(--mare); color: #fff;
  font-size: 13px; font-weight: 600; border: none; cursor: pointer;
  border-radius: 8px; padding: 8px 16px;
}
.btn:hover { background: var(--mare-strong); color: #fff; text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--mare); border: 1px solid #9CC7DD; }
.btn.ghost:hover { background: var(--cielo-soft); }
.btn.danger { background: var(--surface); color: var(--danger); border: 1px solid #DFB1B1; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { font-size: 12px; padding: 5px 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.f { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); font-weight: 600; margin: 12px 0 4px; }
input.f, select.f, textarea.f {
  width: 100%; background: #F4F9FC; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; font-size: 14px; color: var(--ink);
  font-family: inherit;
}
input.f:focus, select.f:focus, textarea.f:focus { outline: 2px solid var(--mare); outline-offset: 1px; }
textarea.f { min-height: 90px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--ink2); margin-top: 3px; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.frow3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.flash { border-radius: 9px; padding: 11px 16px; font-size: 13px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--danger-bg); color: var(--danger); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

.note {
  background: var(--cielo-soft); border-left: 3px solid var(--mare);
  border-radius: 0 8px 8px 0; padding: 10px 14px; font-size: 12.5px; color: var(--ink2);
  margin: 10px 0;
}
.note b { color: var(--mare-strong); }

/* interruttori funzioni */
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #EDF3F8; }
.toggle-row .lbl { font-size: 13.5px; }
.toggle-row .lbl small { display: block; color: var(--ink2); font-size: 11.5px; }
.switch { margin-left: auto; position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #C9D8E1; border-radius: 99px;
  transition: background .15s; cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute; top: 2.5px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .15s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--mare); }

/* calendario */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 12px; text-align: center; }
.cal .dow { color: var(--ink2); font-weight: 600; padding: 4px 0; font-size: 11px; }
.cal .d { background: #F4F9FC; border-radius: 6px; padding: 9px 0 8px; color: var(--ink2); position: relative; }
.cal .d.busy { background: var(--cielo); color: var(--mare-strong); font-weight: 600; }
.cal .d.busy2 { background: var(--mare); color: #fff; font-weight: 600; }
.cal .d.conflict { background: var(--danger-bg); color: var(--danger); font-weight: 700; outline: 1.5px solid var(--danger); }
.cal .d.off { opacity: .35; }
.cal .d.today { outline: 2px solid var(--mare-strong); }
.cal-legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink2); margin-top: 10px; flex-wrap: wrap; }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* allegati / documenti */
.att { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #EDF3F8; font-size: 13px; }
.att .sz { margin-left: auto; color: var(--ink2); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.att form { margin: 0; }

/* messaggi */
.msg { border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 8px; max-width: 85%; }
.msg.host { background: var(--cielo-soft); color: var(--mare-strong); margin-left: auto; }
.msg.guest { background: #F4F9FC; color: var(--ink); }
.msg .meta { font-size: 10.5px; color: var(--ink2); margin-top: 3px; }

/* tab */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink2); border-radius: 8px 8px 0 0; }
.tabs a.on { background: var(--surface); color: var(--mare-strong); border: 1px solid var(--line); border-bottom-color: var(--surface); margin-bottom: -2px; }
.tabs a:hover { text-decoration: none; color: var(--mare); }

/* login standalone */
.auth-body {
  background: linear-gradient(180deg, #DDF0F9, #F4FAFD 400px);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.auth-card {
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 18px 50px -20px rgba(23, 61, 84, .35);
  max-width: 400px; width: 100%; padding: 34px 38px; text-align: center;
}
.auth-card h1 { font-family: Georgia, serif; font-weight: 400; color: var(--mare-strong); font-size: 26px; margin: 6px 0 2px; }
.auth-card .sub { color: var(--ink2); font-size: 13px; margin-bottom: 20px; }
.auth-card form { text-align: left; }

/* responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { border-left: none; border-bottom: 2px solid transparent; padding: 6px 10px; }
  .side nav a.on { border-left: none; border-bottom-color: #7CC1E0; }
  .side .sidefoot { display: none; }
  .grid2, .grid3, .grid-main, .frow, .frow3, .stats { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
