/* ==========================================================================
   ALEX HELPDESK — DESIGN SYSTEM & STYLESHEET
   Morel TV Agency · Palette: #0A0A0A, #1C1C1C, #C39B53, #FEFCFC, #FBD4C8
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  color-scheme: dark;
  
  /* Core Morel Palette */
  --bg: #0A0A0A;
  --surface: #141414;
  --surface-elevated: #1C1C1C;
  --surface-card: #202020;
  --surface-card-hover: #262420;
  --gold: #C39B53;
  --gold-hover: #D8B168;
  --gold-light: #F2DDB3;
  --gold-surface: rgba(195, 155, 83, 0.12);
  --gold-glow: rgba(195, 155, 83, 0.25);
  --text: #FEFCFC;
  --muted: #B7B2AA;
  --line: #3A342B;
  --line-subtle: rgba(58, 52, 43, 0.6);
  --rose: #FBD4C8;
  
  /* Functional Semantic Accents */
  --danger: #E05A47;
  --danger-bg: rgba(224, 90, 71, 0.14);
  --danger-border: rgba(224, 90, 71, 0.4);
  --danger-text: #FF9B9B;
  
  --success: #3EAF76;
  --success-bg: rgba(62, 175, 118, 0.14);
  --success-border: rgba(62, 175, 118, 0.4);
  --success-text: #7FE0B1;
  
  --warning: #E5A83B;
  --warning-bg: rgba(229, 168, 59, 0.14);
  --warning-border: rgba(229, 168, 59, 0.4);
  --warning-text: #FFD480;
  
  --info: #4A90E2;
  --info-bg: rgba(74, 144, 226, 0.14);
  --info-border: rgba(74, 144, 226, 0.4);
  
  /* Typography & Layout Metrics */
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 16px rgba(195, 155, 83, 0.2);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  background-color: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(195, 155, 83, 0.08) 0%, transparent 80%),
    radial-gradient(circle at 90% 20%, rgba(195, 155, 83, 0.03) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

/* Typography Standards */
h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  line-height: 1.3;
}

h3 {
  font-size: 15px;
  line-height: 1.4;
}

p {
  margin: 0 0 10px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 6px;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.muted {
  color: var(--muted);
}

.note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 12px 0 0;
  border-left: 2px solid var(--line-gold);
  padding: 6px 12px;
  background: rgba(195, 155, 83, 0.03);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.5;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
  grid-column: 1 / -1;
  margin: 8px 0 0;
}

/* Form Controls & Inputs */
button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

input, textarea, select {
  display: block;
  width: 100%;
  background: #111111;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
  background: #151515;
}

input::placeholder, textarea::placeholder {
  color: #706B63;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23C39B53' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

select option {
  background: var(--surface-elevated);
  color: var(--text);
}

/* Buttons System */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--text);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  text-decoration: none;
  line-height: 1.25;
}

button:hover {
  border-color: var(--gold);
  background: var(--surface-card-hover);
  color: #FFF;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  border-color: var(--line) !important;
}

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Primary Button (Gold Accent) */
.primary, button.primary {
  background: var(--gold);
  color: #0A0A0A;
  border-color: var(--gold);
  font-weight: 750;
  box-shadow: var(--shadow-gold);
}

.primary:hover, button.primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
  color: #000;
  box-shadow: 0 6px 20px rgba(195, 155, 83, 0.35);
}

/* Danger / Destructive Button */
button.danger, [data-action="close"], button[data-itsm="annullato"], button[data-cfg$="-active"][data-active="0"] {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

button.danger:hover, [data-action="close"]:hover, button[data-itsm="annullato"]:hover, button[data-cfg$="-active"][data-active="0"]:hover {
  background: rgba(224, 90, 71, 0.25);
  border-color: var(--danger);
  color: #FFF;
}

/* ITSM Progression Buttons */
button[data-itsm="in_lavorazione"] {
  border-color: var(--gold);
  background: rgba(195, 155, 83, 0.15);
  color: var(--gold-light);
}

button[data-itsm="in_attesa"] {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

button[data-itsm="risolto"] {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

button[data-confirm] {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 700;
}

/* Layout Framework */
main {
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 3vw;
  flex: 1;
}

/* ==========================================================================
   HEADER & TOP BAR
   ========================================================================== */
.op-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 16px 3vw;
  background: rgba(14, 14, 14, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-home {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.brand-home:hover {
  transform: none;
}

h1 button.brand-home {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

h1 button.brand-home span {
  font-weight: 400;
  color: var(--gold);
  margin-left: 2px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(28, 28, 28, 0.8);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gold-light);
}

#identity::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.header-actions button {
  padding: 7px 13px;
  font-size: 13px;
  border-radius: 20px;
}

.header-actions a {
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.header-actions a:hover {
  color: #FFF;
  background: var(--gold-surface);
}

/* ==========================================================================
   STATUS LINE & BANNER
   ========================================================================== */
#statusLine {
  background: var(--surface-elevated);
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 13.5px;
  color: var(--gold-light);
  box-shadow: var(--shadow-sm);
  animation: slideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  background: rgba(28, 28, 28, 0.7);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
}

.banner strong {
  color: var(--gold);
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
}

.banner span {
  color: var(--muted);
}

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */
.op-tabs {
  display: flex;
  gap: 6px;
  margin: 20px 0 24px;
  padding: 5px;
  background: #111111;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  scrollbar-width: none;
}

.op-tabs::-webkit-scrollbar {
  display: none;
}

.op-tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.op-tabs button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  transform: none;
}

.op-tabs button.active {
  background: var(--surface-elevated);
  color: var(--gold);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.tabs-spacer {
  flex: 1;
}

.op-tabs .settings-tab {
  color: #8C867D;
}

.op-tabs .settings-tab.active {
  color: var(--gold);
}

/* ==========================================================================
   LOGIN PANEL
   ========================================================================== */
.login {
  max-width: 440px;
  margin: 60px auto;
  padding: 38px 34px;
  border: 1px solid var(--line);
  background: var(--surface-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md), 0 0 40px rgba(195, 155, 83, 0.05);
}

.login h2 {
  font-size: 24px;
  margin: 0 0 8px;
}

.login p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.login form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}

.login form input {
  margin-top: 6px;
}

.login form button {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 10px;
}

/* ==========================================================================
   PANEL HOME & STATS CARDS
   ========================================================================== */
#panel-home {
  animation: fadeIn 0.25s ease-out;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin: 22px 0 28px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.2s ease;
}

.stat:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), 0 0 20px rgba(195, 155, 83, 0.12);
}

.stat:hover::before {
  background: var(--gold);
}

.stat-n {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--gold);
  margin-bottom: 8px;
}

.stat-t {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.stat .meta {
  font-size: 12.5px;
  color: var(--muted);
}

/* ==========================================================================
   CONTROLS BAR (Search, Filters, Scope Pills, Actions)
   ========================================================================== */
.op-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  margin: 0 0 22px;
  box-shadow: var(--shadow-sm);
}

/* Primary search input */
.op-controls input[type="search"] {
  flex: 1 1 260px;
  min-width: 220px;
  margin: 0;
  background: #0E0E0E;
  border-radius: 30px;
  padding: 9px 16px 9px 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23C39B53' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
}

.op-controls select {
  width: auto;
  min-width: 150px;
  margin: 0;
  padding: 8px 30px 8px 12px;
  font-size: 13.5px;
  background-color: var(--surface-elevated);
}

#counterBadge {
  color: var(--gold-light);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
  background: #101010;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--line-subtle);
}

.op-controls button {
  padding: 9px 16px;
  font-size: 13.5px;
}

#newTicketButton {
  order: 10;
}

#demoButton {
  order: 11;
  background: rgba(195, 155, 83, 0.08);
  border-color: var(--line-gold);
  color: var(--gold-light);
}

#demoButton:hover {
  background: rgba(195, 155, 83, 0.18);
  border-color: var(--gold);
}

/* Scope Pills Bar */
.scope-pills-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  padding-bottom: 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line-subtle);
}

.scope-pill {
  border: 1px solid var(--line);
  background: #111111;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.scope-pill:hover {
  border-color: var(--gold);
  color: var(--text);
  transform: none;
}

.scope-pill.active {
  background: var(--gold);
  color: #0A0A0A;
  border-color: var(--gold);
  font-weight: 750;
  box-shadow: 0 2px 8px rgba(195, 155, 83, 0.3);
}

/* Active Category Drill-down Pill Bar */
.category-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(195, 155, 83, 0.12);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--gold-light);
}

.category-filter-bar strong {
  color: var(--text);
  margin-left: 4px;
}

.btn-clear-cat {
  background: transparent;
  border: 1px solid rgba(195, 155, 83, 0.4);
  color: var(--gold);
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-clear-cat:hover {
  background: var(--gold);
  color: #0A0A0A;
  border-color: var(--gold);
}

/* ==========================================================================
   SPLIT WORKSPACE: LIST & DETAIL
   ========================================================================== */
.split {
  display: grid;
  grid-template-columns: minmax(320px, 38%) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.list-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.op-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* Ticket & Conversation Row */
.row {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line-subtle);
  border-radius: 0;
  padding: 16px 18px;
  background: transparent;
  position: relative;
  transition: all 0.18s ease;
  cursor: pointer;
}

.row:last-child {
  border-bottom: 0;
}

.row:hover {
  background: rgba(255, 255, 255, 0.03);
  transform: none;
}

.row.selected {
  background: #251F16;
  border-left: 4px solid var(--gold);
  padding-left: 14px;
  box-shadow: inset 0 0 20px rgba(195, 155, 83, 0.08);
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.row-top strong {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #8C867D;
}

#loadMore {
  align-self: center;
  padding: 10px 24px;
  font-size: 13.5px;
  border-radius: 20px;
}

/* ==========================================================================
   BADGES & PILLS
   ========================================================================== */
.badge {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2px 8px;
  color: var(--rose);
  background: rgba(251, 212, 200, 0.08);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Priority Badges */
.badge-p1, [data-prio-code="P1"] {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  font-weight: 750;
}

.badge-p2, [data-prio-code="P2"] {
  border-color: var(--line-gold);
  background: var(--gold-surface);
  color: var(--gold-light);
  font-weight: 700;
}

.badge-p3, [data-prio-code="P3"] {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-p4, .badge-p5 {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.badge-eval, [data-prio-code="da_valutare"] {
  border-color: rgba(163, 146, 196, 0.4);
  background: rgba(163, 146, 196, 0.12);
  color: #D6C7F0;
}

/* ==========================================================================
   DETAIL VIEW (The Core Redesign!)
   ========================================================================== */
.detail {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.empty {
  padding: 60px 40px;
  text-align: center;
  color: var(--muted);
}

.empty h2 {
  font-size: 22px;
  margin: 10px 0;
  color: var(--text);
}

.empty p {
  max-width: 380px;
  margin: 0 auto;
  font-size: 14px;
}

/* Detail Header & Action Disposition */
.detail-head {
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(28, 28, 28, 0.6) 0%, rgba(20, 20, 20, 0) 100%);
}

.detail-heading-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.detail-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  background: #111111;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--gold);
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
  margin-top: 2px;
}

.detail-back:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #0A0A0A;
  transform: translateX(-2px);
}

.detail-heading-text {
  flex: 1;
  min-width: 0;
}

.detail-heading-text .eyebrow {
  margin: 0 0 4px;
  font-size: 11.5px;
}

.detail-heading-text h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
  color: #FFF;
  overflow-wrap: anywhere;
}

.detail-head .meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line-subtle);
  margin-top: 12px;
}

/* Operator Actions Toolbar */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-subtle);
}

/* Distinct Action Buttons */
[data-action="claim"] {
  background: var(--gold);
  border-color: var(--gold);
  color: #0A0A0A;
  font-weight: 750;
  box-shadow: 0 2px 10px rgba(195, 155, 83, 0.25);
}

[data-action="claim"]:hover:not(:disabled) {
  background: var(--gold-hover);
  color: #000;
}

[data-action="reactivate"] {
  border-color: var(--line-gold);
  color: var(--gold-light);
  background: rgba(195, 155, 83, 0.08);
}

[data-action="close"] {
  margin-left: auto;
}

/* ==========================================================================
   SCHEDA CLIENTE & CARDS
   ========================================================================== */
.scheda {
  border-top: 1px solid var(--line);
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  background: rgba(16, 16, 16, 0.4);
}

.scheda .eyebrow {
  grid-column: 1 / -1;
  margin: 0 0 4px;
}

.grp {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
}

.grp h3 {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 750;
  border-bottom: 1px solid var(--line-subtle);
  padding-bottom: 8px;
}

.f {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid #231E17;
}

.f:first-of-type {
  border-top: 0;
}

.f-l {
  flex-basis: 160px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.f-v {
  flex: 1;
  min-width: 130px;
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.f-v.muted {
  font-style: italic;
  color: #8C867D;
}

/* State tags for customer fields */
.st {
  font-size: 10.5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 7px;
  color: var(--muted);
  white-space: nowrap;
}

.st-confirmed {
  color: var(--gold);
  border-color: var(--line-gold);
  background: var(--gold-surface);
  font-weight: 700;
}

.st-provided {
  color: var(--rose);
  border-color: rgba(251, 212, 200, 0.3);
  background: rgba(251, 212, 200, 0.06);
}

.st-refused {
  color: var(--danger-text);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

/* ITSM Classification card inside Scheda */
.scheda .grp:first-of-type {
  grid-column: 1 / -1;
  background: #181613;
  border-color: var(--line-gold);
}

.scheda .grp:first-of-type h3 {
  color: var(--gold);
}

/* ==========================================================================
   CONVERSATION MESSAGES & CHAT THREAD
   ========================================================================== */
.messages {
  padding: 24px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #0E0E0E;
  border-top: 1px solid var(--line);
}

#olderButton {
  align-self: center;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.message {
  padding: 14px 18px;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 85%;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.15s ease-out;
}

.message.inbound {
  align-self: flex-start;
  border-bottom-left-radius: 2px;
  border-color: #2F2A22;
}

.message.outbound {
  align-self: flex-end;
  background: #252017;
  border-color: var(--line-gold);
  border-bottom-right-radius: 2px;
}

.message .meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.message .meta strong {
  font-size: 13px;
  color: var(--gold-light);
}

.message p {
  margin: 4px 0 8px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message span.meta {
  font-size: 11px;
  color: #8C867D;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   COMPOSER (Reply & Notes)
   ========================================================================== */
.composer {
  border-top: 1px solid var(--line);
  padding: 20px 24px;
  background: var(--surface-elevated);
}

.composer label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.composer textarea {
  resize: vertical;
  min-height: 110px;
  margin-bottom: 12px;
  background: #101010;
  font-size: 14px;
}

.composer button {
  padding: 10px 20px;
  font-size: 14px;
}

.composer p {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 0;
}

/* ==========================================================================
   INTERNAL NOTES & HISTORY
   ========================================================================== */
.notes {
  border-top: 1px solid var(--line);
  padding: 24px;
  background: #11100E;
}

.noteitem {
  background: #181510;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 10px 0;
}

.noteitem .meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--gold-light);
}

.noteitem p {
  margin: 6px 0 0;
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history {
  border-top: 1px solid var(--line);
  padding: 24px;
}

.histitem {
  background: #131313;
  border: 1px solid var(--line-subtle);
  border-left: 3px solid #555;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 8px 0;
}

.histitem .meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.histitem p {
  margin: 4px 0 0;
  font-size: 13px;
}

/* Coordinator Assignment Form */
.assign {
  border-top: 1px solid var(--line);
  padding: 24px;
  background: #131210;
}

.assign form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  margin-top: 8px;
}

.assign label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.assign #as-reason-wrap {
  grid-column: 1 / -1;
}

.assign button {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 8px;
}

.assign .note {
  grid-column: 1 / -1;
}

/* ==========================================================================
   NEW TICKET FORM
   ========================================================================== */
.ticketform {
  max-width: 900px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-elevated);
  padding: 28px 32px;
  margin-top: 20px;
  box-shadow: var(--shadow-md);
}

.ticketform fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin: 20px 0;
  padding: 20px 22px;
  background: rgba(15, 15, 15, 0.4);
}

.ticketform legend {
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  padding: 0 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

.ticketform label {
  display: block;
  margin: 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.ticketform .chk {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  align-self: end;
  margin-bottom: 22px;
  cursor: pointer;
}

.ticketform .chk input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--gold);
}

.ticketform .actions {
  border-top: 0;
  padding-top: 10px;
}

/* ==========================================================================
   SETTINGS & CONFIGURATION
   ========================================================================== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 20px 0 30px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-sm);
}

.card h3 {
  color: var(--gold);
  font-size: 15px;
  margin: 0 0 8px;
}

#configPanel .scheda {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin: 22px 0;
  grid-template-columns: 1fr;
}

#configPanel ul {
  padding-left: 20px;
  margin: 10px 0;
}

#configPanel li {
  padding: 6px 0;
  line-height: 1.5;
}

/* ==========================================================================
   DIALOGS & MODALS (Native & AskDialog)
   ========================================================================== */
dialog {
  color: var(--text);
  background: #181818;
  border: 1px solid var(--line-gold);
  border-radius: var(--radius-xl);
  padding: 30px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(195, 155, 83, 0.15);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
footer {
  padding: 28px 3vw;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--line-subtle);
  margin-top: 40px;
  text-align: center;
}

footer strong {
  color: var(--gold-light);
}

/* ==========================================================================
   RESPONSIVE DESIGN (Desktop & Mobile Phone Experience)
   ========================================================================== */
@media (max-width: 880px) {
  .op-header {
    padding: 14px 18px;
  }
  
  .header-actions {
    gap: 6px;
  }
  
  #identity {
    font-size: 11.5px;
    padding: 4px 10px;
  }
  
  main {
    padding: 16px 14px;
  }
  
  .split {
    grid-template-columns: 1fr;
  }
  
  /* On mobile: if detail is open, list is hidden or scrolls; clean phone view */
  #detail:not([hidden]) {
    margin-top: 10px;
  }
  
  .op-controls {
    padding: 12px;
    gap: 10px;
  }
  
  .op-controls select {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }
  
  .scheda {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  
  .f-l {
    flex-basis: 100%;
  }
  
  .ff {
    grid-template-columns: 1fr;
  }
  
  .ticketform {
    padding: 20px 16px;
  }
  
  .assign form {
    grid-template-columns: 1fr;
  }
  
  /* Safe touch targets on mobile (44px min) */
  button, input, select, textarea {
    min-height: 44px;
  }
  
  /* Prevent iOS zoom */
  input, textarea, select {
    font-size: 16px;
  }
}

/* ==========================================================================
   SERVICENOW-STYLE ITSM ANALYTICS & VISUAL WIDGETS
   ========================================================================== */
.home-hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.home-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(195, 155, 83, 0.12);
  border: 1px solid var(--line-gold);
  color: var(--gold-light);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.analytics-grid.secondary-grid {
  margin-top: 20px;
}

.analytics-card {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.analytics-card:hover {
  border-color: var(--line-gold);
  box-shadow: var(--shadow-md);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line-subtle);
  padding-bottom: 12px;
}

.card-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 750;
  margin: 0 0 4px;
}

.card-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-badge-info {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: #25221B;
  border: 1px solid var(--line);
  color: var(--gold-light);
}

.card-badge-alert {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

/* Category Donut & Bars Layout */
.donut-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 24px;
  align-items: center;
}

.donut-svg-wrap {
  width: 160px;
  height: 160px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.donut-center-text {
  position: absolute;
  text-align: center;
  pointer-events: none;
}

.donut-center-n {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.donut-center-l {
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  margin-top: 4px;
}

.category-bars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-bar-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.cat-bar-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cat-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.cat-name-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.cat-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-count-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.progress-track {
  height: 6px;
  background: #101010;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--line-subtle);
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Priority Matrix ServiceNow Bars */
.priority-matrix-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prio-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(14, 14, 14, 0.6);
  border: 1px solid var(--line-subtle);
  transition: all 0.15s ease;
}

.prio-row:hover {
  border-color: var(--gold);
  transform: translateX(2px);
  background: rgba(30, 26, 20, 0.6);
}

.prio-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.prio-label-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Lifecycle Pipeline */
.pipeline-bar-wrapper {
  margin-top: 8px;
}

.pipeline-track {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.pipeline-segment {
  height: 100%;
  transition: width 0.4s ease;
}

.pipeline-stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
}

.stage-pill {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: #141414;
  border: 1px solid var(--line);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.stage-pill:hover {
  border-color: var(--gold);
}

.stage-pill-n {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stage-pill-l {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

/* Critical Focus List */
.critical-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.critical-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #131211;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
  cursor: pointer;
}

.critical-item:hover {
  border-color: var(--gold);
  background: #1F1B14;
}

.critical-info {
  min-width: 0;
  flex: 1;
}

.critical-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.critical-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.critical-meta {
  font-size: 12px;
  color: var(--muted);
}

.critical-cta {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(195, 155, 83, 0.1);
  border: 1px solid var(--line-gold);
}

.critical-item:hover .critical-cta {
  background: var(--gold);
  color: #0A0A0A;
}

@media (max-width: 880px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .category-bars-list {
    width: 100%;
  }
}

/* ==========================================================================
   SETTINGS & CLIENT-FACING SERVICES
   ========================================================================== */
.settings-hero-header {
  margin-bottom: 24px;
}

.client-services-section {
  margin-bottom: 28px;
}

.section-title-wrap {
  margin-bottom: 18px;
}

.section-title-wrap h3 {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--text);
}

.client-channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.service-channel-card {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.service-channel-card:hover {
  border-color: var(--line-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.channel-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.channel-icon {
  font-size: 26px;
  line-height: 1;
}

.channel-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  letter-spacing: 0.02em;
}

.channel-status-pill.status-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.channel-status-pill.status-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: #8CC4FF;
}

.channel-status-pill.status-gold {
  background: var(--gold-surface);
  border: 1px solid var(--line-gold);
  color: var(--gold-light);
}

.service-channel-card h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}

.channel-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 16px;
  flex: 1;
}

.channel-footer {
  padding-top: 12px;
  border-top: 1px solid var(--line-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-detail-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gold-light);
  font-weight: 600;
}

/* Tech Diagnostics Drawer (Foldable for Coordinator/Internal) */
.tech-diagnostics-drawer {
  background: #11100E;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin: 24px 0;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.tech-diagnostics-drawer[open] {
  border-color: var(--line-gold);
}

.tech-diagnostics-summary {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: rgba(22, 20, 18, 0.7);
  user-select: none;
  list-style: none;
}

.tech-diagnostics-summary::-webkit-details-marker {
  display: none;
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.tech-icon {
  font-size: 16px;
}

.toggle-hint {
  font-size: 12px;
  color: var(--muted);
}

.tech-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 20px;
  border-top: 1px solid var(--line-subtle);
  background: #0E0E0E;
}

.tech-card-item {
  background: #151413;
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.tech-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}

.tech-card-top strong {
  color: var(--muted);
}

.tech-card-val {
  font-size: 13px;
  color: var(--text);
  margin: 0;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

/* La cabecera se apila en móvil para no comprimir el texto. */
@media (max-width: 640px) {
  .home-hero-header { flex-direction: column; }
  .home-hero-header > div { width: 100%; min-width: 0; }
  .home-hero-badge { white-space: normal; width: auto !important; }
}
