/* Supabase-inspired UI language, preserving Grindbook's existing palette. */
:root{
  --ui-radius-xs:4px;
  --ui-radius-sm:6px;
  --ui-radius-md:8px;
  --ui-space-1:4px;
  --ui-space-2:8px;
  --ui-space-3:12px;
  --ui-space-4:16px;
  --ui-space-5:24px;
  --ui-space-6:32px;
  --ui-control:#262626;
  --ui-control-hover:#2d2d2d;
  --ui-surface:#1c1c1c;
  --ui-surface-raised:#202020;
  --ui-border:#343434;
  --ui-border-soft:#2b2b2b;
  --ui-text:#ededed;
  --ui-text-muted:#9b9b9b;
}

html,body,button,input,select,textarea,dialog,table{
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif!important;
}
html{font-size:14px}
body{
  color:var(--ui-text);
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
button,input,select,textarea{font-size:13px}

/* Application frame */
.shell{grid-template-columns:240px minmax(0,1fr);grid-template-rows:58px minmax(calc(100vh - 58px),auto)}
header{height:58px;padding:0 var(--ui-space-5);background:#191919;border-color:var(--ui-border-soft)}
.tabs{padding:82px var(--ui-space-3) var(--ui-space-4);gap:2px;background:#131313;border-color:var(--ui-border-soft)}
.tabs::before{top:22px;left:23px;font-size:16px;letter-spacing:.1em}
.tabs::after{top:47px;left:49px;font-size:8px}
.tab{
  min-height:38px;
  gap:var(--ui-space-3);
  padding:8px 11px;
  border:1px solid transparent;
  border-radius:var(--ui-radius-sm);
  color:var(--ui-text-muted);
  font-size:13px;
  font-weight:500;
}
.tab:hover{background:#1d1d1d;border-color:#292929;color:var(--ui-text)}
.tab.active{background:#26220d;border-color:#4c4215;box-shadow:none;color:var(--accent);font-weight:600}
.shell.sidebar-collapsed{grid-template-columns:64px minmax(0,1fr)}
.shell.sidebar-collapsed .tabs{padding:74px 8px 16px}
.shell.sidebar-collapsed .tab{padding:8px}
.view{padding:var(--ui-space-5) var(--ui-space-6) 48px}
.app-credits{
  grid-column:2;
  width:100%;
  min-width:0;
}

/* Typography */
h1,h2,h3,h4{color:var(--ui-text);font-weight:600;letter-spacing:-.015em}
.panel h2,.modal-card h2,dialog h2{font-size:16px;font-weight:600;line-height:1.35;letter-spacing:-.015em}
.panel h3,dialog h3{font-size:14px;font-weight:600}
p,.tournament-help,.catalog-guidance,.group-note{line-height:1.55}
label{
  color:#aaa;
  font-size:12px;
  font-weight:500;
  letter-spacing:0;
  text-transform:none;
}
small{font-size:12px}

/* Surfaces */
.panel{
  padding:var(--ui-space-4);
  background:var(--ui-surface);
  border:1px solid var(--ui-border);
  border-radius:var(--ui-radius-md);
  box-shadow:none;
}
.card{
  padding:var(--ui-space-4);
  background:var(--ui-surface-raised);
  border-color:var(--ui-border);
  border-radius:var(--ui-radius-sm);
  box-shadow:none;
}
.card .k{font-size:11px;font-weight:500;letter-spacing:.045em}
.card .v{margin-top:var(--ui-space-2);font-size:22px;font-weight:600;letter-spacing:-.03em}
.cards{gap:var(--ui-space-3)}
.dash,.dashboard-groups{gap:var(--ui-space-4)!important}

/* Controls */
button{
  min-height:34px;
  padding:7px 12px;
  border:1px solid #3a3a3a;
  border-radius:var(--ui-radius-sm);
  background:var(--ui-control);
  color:var(--ui-text);
  font-weight:500;
  line-height:1.25;
  box-shadow:0 1px 1px rgba(0,0,0,.16);
}
button:hover{filter:none;background:var(--ui-control-hover);border-color:#484848}
button:active{transform:translateY(1px);box-shadow:none}
button.primary,.filters button:first-of-type{
  background:var(--accent);
  border-color:var(--accent);
  color:#17130a;
  font-weight:600;
}
button.primary:hover,.filters button:first-of-type:hover{background:#ffd329;border-color:#ffd329}
button.danger{border-color:transparent;background:transparent;color:var(--red);box-shadow:none}
button.danger:hover{border-color:rgba(241,116,120,.25);background:rgba(241,116,120,.08)}
.app-sidebar-toggle{width:34px;height:34px;border-radius:var(--ui-radius-sm);background:var(--ui-control);box-shadow:none}
.user-avatar{width:34px;height:34px;flex-basis:34px;font-size:11px;box-shadow:none}

input,select,textarea{
  min-height:36px;
  margin-top:var(--ui-space-1);
  padding:7px 10px;
  border:1px solid #3a3a3a;
  border-radius:var(--ui-radius-sm);
  background:#171717;
  color:var(--ui-text);
  line-height:1.35;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.015);
}
input:hover,select:hover,textarea:hover{border-color:#484848}
input:focus,select:focus,textarea:focus,button:focus-visible{
  outline:2px solid color-mix(in srgb,var(--accent) 65%,transparent);
  outline-offset:1px;
  border-color:#75631a;
}
input::placeholder,textarea::placeholder{color:#6f6f6f}
.check{min-height:0;box-shadow:none}

/* Toolbars and navigation inside views */
.quick,.filters,.schedule-toolbar,.dashboard-subtabs,.indicator-tabs,.schedule-panel-menu{
  gap:var(--ui-space-2)!important;
}
.quick{margin-bottom:var(--ui-space-3)}
.schedule-panel-menu{
  padding:var(--ui-space-2)!important;
  border:1px solid var(--ui-border)!important;
  border-radius:var(--ui-radius-md)!important;
  background:#191919!important;
  box-shadow:none!important;
}
.schedule-panel-menu button{border-color:transparent;background:transparent;box-shadow:none}
.schedule-panel-menu button:hover,.schedule-panel-menu button[aria-expanded="true"]{background:#28240f;border-color:#4d4319;color:var(--accent)}
.dashboard-subtabs button,.indicator-tabs button{border-radius:var(--ui-radius-sm)!important}

/* Tables */
.table-wrap{border:1px solid var(--ui-border-soft);border-radius:var(--ui-radius-sm);background:#191919}
table{border-collapse:separate;border-spacing:0;font-size:13px;font-variant-numeric:tabular-nums}
thead{background:#1f1f1f}
th{
  height:38px;
  padding:9px 10px;
  border-bottom:1px solid var(--ui-border);
  color:#a4a4a4;
  font-size:10px;
  font-weight:600;
  letter-spacing:.055em;
  line-height:1.2;
}
td{padding:9px 10px;border-top:0;border-bottom:1px solid var(--ui-border-soft);font-size:12px}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover td{background:#202020}
td input,td select{min-height:30px;padding:5px 8px}
.status{padding:3px 7px;border:1px solid #45412f;border-radius:999px;background:#29271e;font-size:11px}

/* Dialogs and overlays */
.modal{background:rgba(0,0,0,.7);backdrop-filter:blur(2px)}
.modal-card,dialog,.cloud-dialog,.sharkscope-import-dialog{
  background:#1d1d1d!important;
  border:1px solid #3b3b3b!important;
  border-radius:var(--ui-radius-md)!important;
  box-shadow:0 24px 70px rgba(0,0,0,.45)!important;
}
.modal-card{padding:var(--ui-space-5)}
.modal-actions{gap:var(--ui-space-2);margin-top:var(--ui-space-5);padding-top:var(--ui-space-4);border-top:1px solid var(--ui-border-soft)}
.schedule-overlay-panel{border-radius:var(--ui-radius-md)!important;box-shadow:0 24px 64px rgba(0,0,0,.45)!important}
.schedule-overlay-close{border-radius:var(--ui-radius-sm)!important}

/* Cards and repeated list items */
.template-item,.catalog-card,.catalog-list-row,.schedule-summary-card,.exposure-card,.risk-card,.indicator-card{
  border-radius:var(--ui-radius-sm)!important;
  box-shadow:none!important;
}
.template-item{padding:var(--ui-space-3);background:#191919}
.empty{padding:var(--ui-space-6) var(--ui-space-4);color:var(--ui-text-muted)}

/* Compact desktop density; retain existing responsive behaviour. */
@media(max-width:950px){
  .view{padding:var(--ui-space-4)}
  .shell{grid-template-columns:210px minmax(0,1fr)}
}
@media(max-width:640px){
  html{font-size:13px}
  .panel{padding:var(--ui-space-3)}
  .view{padding:var(--ui-space-3)}
}

/* Second pass: closer to the compact Supabase project dashboard. */
.shell{
  grid-template-columns:208px minmax(0,1fr);
  grid-template-rows:46px minmax(calc(100vh - 46px),auto);
  background:#151515;
}
header{
  height:46px;
  padding:0 18px;
  background:#161616;
  border-bottom-color:#292929;
}
.header-right{gap:8px!important}
.app-sidebar-toggle,.user-avatar{width:30px;height:30px;min-height:30px}
.user-avatar{flex-basis:30px}
.app-sidebar-toggle svg{width:17px;height:17px}

.tabs{
  width:208px;
  padding:66px 8px 12px;
  background:#121212;
  border-right-color:#292929;
}
.tabs::before{top:17px;left:18px;font-size:14px;letter-spacing:.11em}
.tabs::after{top:39px;left:42px;font-size:7px;color:#686868}
.tabs::before,.tabs::after{display:none}
.app-brand{
  position:absolute;
  top:10px;
  left:12px;
  right:10px;
  height:38px;
  display:flex;
  align-items:center;
  gap:10px;
  overflow:hidden;
  color:var(--accent);
  font-size:13px;
  font-weight:650;
  letter-spacing:.085em;
  white-space:nowrap;
}
.app-brand img{
  width:29px;
  height:29px;
  flex:0 0 29px;
  object-fit:cover;
  border-radius:4px;
}
.tab{
  min-height:34px;
  padding:6px 9px;
  border-radius:4px;
  font-size:12px;
}
.tab::before{font-size:14px!important}
.tab.active{background:#24210f;border-color:#3d3718;box-shadow:inset 2px 0 0 var(--accent)}
.shell.sidebar-collapsed{grid-template-columns:48px minmax(0,1fr)}
.shell.sidebar-collapsed .tabs{width:48px;padding:54px 5px 10px}
.shell.sidebar-collapsed .tabs::before{top:15px;font-size:17px}
.shell.sidebar-collapsed .app-brand{left:9px;right:9px;justify-content:center}
.shell.sidebar-collapsed .app-brand img{width:27px;height:27px;flex-basis:27px}
.shell.sidebar-collapsed .app-brand span{display:none}
.shell.sidebar-collapsed .tab{min-height:34px;padding:6px}
.shell.sidebar-collapsed .schedule-overlay-panel{width:min(1120px,calc(100vw - 92px))}
.shell.sidebar-collapsed #scheduleCatalogPanel{width:min(1480px,calc(100vw - 76px))}

.view{
  width:100%;
  max-width:1680px;
  margin:0 auto;
  padding:36px 48px 64px;
}

/* Technical section hierarchy. */
.panel h2,
.modal-card h2,
dialog h2,
.dashboard-evolution-head h2,
.sessions-header h2,
.schedule-panel-menu+* h2{
  margin-bottom:14px;
  color:#d6d6d6;
  font-size:12px;
  font-weight:600;
  line-height:1.3;
  letter-spacing:.075em;
  text-transform:uppercase;
}
.panel h3,dialog h3{
  color:#c5c5c5;
  font-size:11px;
  font-weight:600;
  letter-spacing:.065em;
  text-transform:uppercase;
}
.panel{
  background:#191919;
  border-color:#2e2e2e;
  border-radius:6px;
}
.view>.panel,.dash>.panel,.dashboard-page>.panel{
  box-shadow:none;
}
.cards .card,.sessions-cards>*{
  background:#191919;
  border-color:#2e2e2e;
}
.card .k{color:#858585;font-size:9px;letter-spacing:.08em}
.card .v{font-size:20px;font-weight:500}

/* Thin, infrastructure-like toolbars. */
.schedule-panel-menu{
  min-height:42px;
  padding:4px!important;
  border-color:#2d2d2d!important;
  border-radius:6px!important;
  background:#171717!important;
}
.schedule-panel-menu button{
  min-height:32px;
  padding:6px 10px;
  border-radius:4px;
  color:#999;
  font-size:11px;
}
.schedule-panel-menu button span{color:#777}
.schedule-panel-menu button:hover,.schedule-panel-menu button[aria-expanded="true"]{color:var(--accent)}
.filters{padding:12px 14px}

/* Supabase-like controls: restrained until active. */
button{
  min-height:30px;
  padding:6px 10px;
  border-color:#363636;
  border-radius:5px;
  background:#222;
  font-size:12px;
  font-weight:500;
}
input,select,textarea{
  min-height:32px;
  padding:6px 9px;
  border-color:#343434;
  border-radius:5px;
  background:#151515;
  font-size:12px;
}
.quick input{max-width:300px}
.status{border-radius:4px}

/* Denser data grids, matching the monitoring cards in the reference. */
.table-wrap{border-color:#2d2d2d;border-radius:5px;background:#171717}
thead{background:#1a1a1a}
th{
  height:34px;
  padding:8px 9px;
  border-bottom-color:#303030;
  color:#888;
  font-size:9px;
  letter-spacing:.08em;
}
td{padding:8px 9px;border-bottom-color:#292929;font-size:11px}
tbody tr:hover td{background:#1e1e1e}

/* Overlays retain focus but lose the oversized consumer-app treatment. */
.modal-card,dialog,.cloud-dialog,.sharkscope-import-dialog,.schedule-overlay-panel{
  border-radius:6px!important;
  border-color:#343434!important;
  background:#191919!important;
  box-shadow:0 18px 50px rgba(0,0,0,.38)!important;
}
.modal-actions{margin-top:18px;padding-top:12px}

@media(max-width:1100px){
  .view{padding:24px}
  .shell{grid-template-columns:180px minmax(0,1fr)}
  .tabs{width:180px}
}

/* Schedule · CAPS: one complete, scan-friendly view without an inner scrollbar. */
#scheduleExposurePanel{
  width:min(1440px,calc(100vw - 260px))!important;
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
}
#scheduleExposurePanel .schedule-exposure{
  margin:0;
  padding:0;
}
#scheduleExposurePanel .schedule-exposure-body{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px 14px;
  align-items:start;
}
#scheduleExposurePanel .schedule-exposure-body>.schedule-exposure-section{
  min-width:0;
  margin-top:0;
}
#scheduleExposurePanel .schedule-exposure-body>:not(.schedule-exposure-section){
  grid-column:1 / -1;
}
#scheduleExposurePanel .schedule-exposure-reference{
  margin:2px 0 4px;
}
#scheduleExposurePanel .schedule-exposure-note,
#scheduleExposurePanel .schedule-exposure-warning{
  margin:0;
}
#scheduleExposurePanel .schedule-exposure-content{
  padding-top:8px;
}
#scheduleExposurePanel .schedule-exposure-metrics{
  margin:0 0 8px;
}
#scheduleExposurePanel .schedule-exposure-grid{
  gap:8px;
}
#scheduleExposurePanel .schedule-exposure-bucket{
  padding:8px 9px;
}
#scheduleExposurePanel .schedule-exposure-bucket .schedule-exposure-bars{
  gap:6px;
  margin:6px 0 2px;
}
@media(max-width:1180px){
  #scheduleExposurePanel{
    width:calc(100vw - 220px)!important;
  }
  #scheduleExposurePanel .schedule-exposure-body{
    grid-template-columns:1fr;
  }
  #scheduleExposurePanel .schedule-exposure-body>*{
    grid-column:1!important;
  }
  #scheduleExposurePanel .schedule-exposure-grid{
    grid-template-columns:repeat(6,minmax(0,1fr));
  }
}
@media(max-width:760px){
  #scheduleExposurePanel{
    width:calc(100vw - 24px)!important;
  }
  #scheduleExposurePanel .schedule-exposure-grid{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
}
