/* ensure [hidden] wins */
[hidden]{display:none !important;}

:root{
  /* Light Mode (Off-white/Grey) */
  --bg: #f5f5f5;
  --surface: #ececec;
  --card: #ffffff;
  --line: #d1d1d1;
  --line-dark: #1a1a1a;
  --text: #1a1a1a;
  --muted: #666666;
  --accent: #000000;
  
  --radius: 2px;
  --topbar-h: 56px;
  --sidebar-w: 240px;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --card: #242424;
  --line: #333333;
  --line-dark: #ffffff;
  --text: #e0e0e0;
  --muted: #999999;
  --accent: #ffffff;
}

html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Layout Structure */
.shell { display: flex; flex-direction: column; height: 100vh; }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  z-index: 100;
}

.menu-trigger {
  background: none; border: none; cursor: pointer; padding: 8px;
  display: flex; flex-direction: column; gap: 4px; margin-right: 20px;
  width: 34px; height: 34px; align-items: center; justify-content: center;
}
.menu-trigger span { 
  width: 18px; height: 2px; background: var(--text); 
  transition: transform 0.3s, opacity 0.3s;
}

.menu-trigger.is-active span:nth-child(1) {
  opacity: 0;
  transform: translateX(-10px);
}
.menu-trigger.is-active span:nth-child(2) {
  transform: rotate(45deg);
}
.menu-trigger.is-active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.brand { display: flex; align-items: center; gap: 12px; margin-right: 40px; cursor: pointer; }
.logo {
  width: 24px; height: 24px; border: 1px solid var(--line-dark);
  display: grid; place-items: center; background: var(--accent); color: var(--bg);
  font-weight: 700; font-size: 12px;
}
.brandName { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; }

.daily-apps { display: flex; height: 100%; gap: 1px; background: var(--line); white-space: nowrap; overflow: hidden; }
.daily-tab {
  background: var(--card); border: none; padding: 0 20px; cursor: pointer;
  color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase;
  transition: all 0.1s; flex: 0 0 auto;
}
.daily-tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.workflow-switcher-wrap{
  display:none;
  align-items:center;
  gap:8px;
  margin-left:8px;
}
.workflow-switcher-label{
  font-size:10px;
  color:var(--muted);
  text-transform:uppercase;
  font-weight:700;
  letter-spacing:.08em;
}
.workflow-switcher{
  height:30px;
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  border-radius: var(--radius);
  padding:0 10px;
  font-size:12px;
  min-width: 170px;
}

.global-search{
  position: relative;
  margin-left: 16px;
  flex: 1 1 320px;
  max-width: 420px;
}
.global-search-input{
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0 10px;
  font-size: 12px;
}
.global-search-input::placeholder{
  color: var(--muted);
}
.search-dropdown{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  z-index: 200;
  max-height: 60vh;
  overflow: auto;
}
.search-results{
  padding: 6px 0;
}
.search-group{
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.search-item{
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.search-item:hover{
  background: var(--surface);
}
.search-item-main{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.search-item-label{
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-secondary{
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-type{
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}
.search-empty{
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
}

/* Auth overlay */
.auth-overlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 16, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
}
.auth-card{
  width: min(420px, 92vw);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.22);
}
.auth-brand{
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.auth-logo{
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-dark);
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 13px;
}
.auth-title{
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.auth-sub{
  font-size: 12px;
  color: var(--muted);
}
.auth-card h1{
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 700;
}
.auth-message{
  margin: 0 0 14px 0;
  font-size: 12px;
  color: var(--muted);
}
.auth-form{
  display: grid;
  gap: 10px;
}
.auth-form label{
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.auth-form input{
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--card);
  color: var(--text);
  font-size: 12px;
}
.auth-btn{
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--line-dark);
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  cursor: pointer;
}
.auth-btn[disabled]{
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-actions{
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}
.auth-link{
  background: none;
  border: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.auth-status{
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.4;
  min-height: 20px;
  color: var(--muted);
}
.auth-status.error{
  color: #8a0018;
  background: #fdecef;
  border: 1px solid #f3c2cc;
  border-radius: 8px;
  padding: 8px 10px;
}
.auth-status.success{
  color: #0a7a2f;
  background: #e9f7ef;
  border: 1px solid #bfe8cc;
  border-radius: 8px;
  padding: 8px 10px;
}

body.auth-locked .shell{
  filter: blur(1px);
  pointer-events: none;
  user-select: none;
}

.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.theme-toggle {
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 36px;
  height: 36px;
}

.theme-toggle:hover {
  background: var(--surface);
}

.theme-toggle .sun-icon {
  display: none;
}

.theme-toggle .moon-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

.notifications-container { position: relative; display: flex; align-items: center; }

.notifications-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s;
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #ff4d4d;
  border-radius: 50%;
  border: 2px solid var(--card);
}

.notifications-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  display: none;
  flex-direction: column;
  z-index: 1000;
}

.notifications-dropdown.active { display: flex; }

.dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropdown-header span { font-weight: 700; font-size: 12px; text-transform: uppercase; }
.mark-read { background: none; border: none; color: var(--muted); font-size: 11px; cursor: pointer; }
.mark-read:hover { color: var(--text); }

.dropdown-content { max-height: 300px; overflow-y: auto; }

.notification-item {
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.2s;
}

.notification-item:hover { background: var(--surface); }
.notification-item.unread { background: rgba(0,0,0,0.02); border-left: 3px solid var(--accent); }
[data-theme="dark"] .notification-item.unread { background: rgba(255,255,255,0.02); }

.notif-icon { font-size: 18px; }
.notif-text p { font-size: 13px; margin: 0 0 4px 0; line-height: 1.4; }
.notif-text span { font-size: 11px; color: var(--muted); }

.dropdown-footer { padding: 12px; text-align: center; border-top: 1px solid var(--line); }
.dropdown-footer a { font-size: 12px; color: var(--text); text-decoration: none; font-weight: 600; }
.dropdown-footer a:hover { text-decoration: underline; }

/* Sidebar (Hamburger Menu) */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: calc(-1 * var(--sidebar-w));
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--card);
  border-right: 1px solid var(--line);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
}
.sidebar.open {
  transform: translateX(var(--sidebar-w));
}

/* User Menu */
.user-menu-container {
  position: relative;
}

.user-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--line-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.2s;
}

.user-btn:hover {
  opacity: 0.8;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  padding: 8px 0;
  z-index: 110;
}

.user-dropdown.active {
  display: flex;
}

.todo-panel{
  position:relative;
  top: auto;
  right: auto;
  width: 100%;
  max-width: 100%;
  max-height: min(72vh, 560px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: auto;
}
.todo-panel[hidden]{ display:none !important; }
.todo-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
}
.todo-head strong{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
}
.todo-close{
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  width:24px;
  height:24px;
  line-height:18px;
}
.todo-tabs{
  display:flex;
  border-bottom:1px solid var(--line);
}
.todo-tab{
  border:none;
  background:transparent;
  color:var(--muted);
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.06em;
  padding:8px 10px;
  cursor:pointer;
}
.todo-tab.active{
  color:var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.todo-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:8px 10px;
  border-bottom:1px solid var(--line);
}
.todo-select{
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  font-size:11px;
  font-weight:700;
  padding:4px 8px;
}
.todo-refresh{
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  font-size:11px;
  font-weight:700;
  padding:4px 8px;
  cursor:pointer;
}
.todo-list{
  overflow:auto;
  min-height: 120px;
  max-height: 360px;
}
.todo-empty{
  padding:14px 12px;
  font-size:12px;
  color:var(--muted);
}
.todo-row{
  border-bottom:1px solid var(--line);
  padding:10px 12px;
}
.todo-title{
  font-size:13px;
  font-weight:700;
  margin-bottom:4px;
}
.todo-meta{
  font-size:11px;
  color:var(--muted);
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:8px;
}
.todo-actions{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}
.todo-badge{
  display:inline-flex;
  align-items:center;
  padding:2px 6px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--card);
  color:var(--muted);
  font-size:10px;
  font-weight:700;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.todo-btn{
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  font-size:11px;
  font-weight:700;
  padding:4px 8px;
  cursor:pointer;
}
.todo-btn.primary{
  border-color: var(--line-dark);
  background: var(--accent);
  color: var(--bg);
}
.todo-create{
  border-top:1px solid var(--line);
  display:flex;
  gap:8px;
  padding:8px 10px;
}
.todo-create .todo-select{
  width:92px;
  flex:0 0 auto;
}
.todo-create input{
  flex:1;
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  padding:6px 8px;
  font-size:12px;
}
.todo-create button{
  border:1px solid var(--line-dark);
  background:var(--accent);
  color:var(--bg);
  padding:6px 9px;
  font-size:11px;
  font-weight:700;
  cursor:pointer;
}

.user-info {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-info strong {
  font-size: 13px;
  color: var(--text);
}

.user-info span {
  font-size: 11px;
  color: var(--muted);
}

.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.dropdown-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.dropdown-item:hover {
  background: var(--bg);
}

.dropdown-item.logout {
  color: #d32f2f;
}

[data-theme="dark"] .dropdown-item.logout {
  color: #ff5252;
}

.sidebar-scroll{ flex:1; overflow:auto; padding:14px 0; }
.sidebar-section-title{
  padding: 0 24px 8px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
}
.sidebar-divider{
  height:1px;
  background: var(--line);
  margin: 8px 0;
}
.sidebar-nav { padding: 0; }
.sidebar-item {
  width: 100%; text-align: left; background: none; border: none;
  padding: 12px 24px; cursor: pointer; color: var(--text);
  font-size: 13px; font-weight: 500;
}
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active { font-weight: 700; background: var(--surface); }

.sidebar-footer {
  padding: 20px; border-top: 1px solid var(--line);
  font-family: ui-monospace, monospace; font-size: 10px; color: var(--muted);
}

/* Main Content */
.main-container { flex: 1; display: flex; overflow: hidden; }
.content-canvas { flex: 1; background: var(--bg); position: relative; overflow: auto; }

.access-denied{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:24px;
  background:var(--bg);
}
.access-denied h2{
  margin:0 0 10px;
  font-size:24px;
  text-transform:uppercase;
  letter-spacing:-.02em;
}
.access-denied p{
  margin:0 0 18px;
  color:var(--muted);
  font-size:13px;
}
.access-denied-btn{
  border:1px solid var(--line-dark);
  background:var(--accent);
  color:var(--bg);
  padding:9px 12px;
  font-weight:700;
  font-size:12px;
  text-transform:uppercase;
  cursor:pointer;
}

/* Overlay when sidebar is open */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.2);
  z-index: 80; display: none;
}
.overlay.active { display: block; }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); }

/* NordCut runtime additions */
.app-frame{ width:100%; pointer-events:auto; min-height: calc(100vh - 160px); border:0; background: transparent; }

/* make sidebar links feel clickable */
.sidebar-nav a{ cursor:pointer; }


/* Admin status bar (only when debug.statusbar) */
.statusBar{
  position:fixed;
  left:0; right:0; bottom:0;
  height:28px;
  background:rgba(11,13,18,.92);
  color:#e5e7eb;
  font:12px/28px ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  padding:0 12px;
  z-index:95;
  border-top:1px solid rgba(255,255,255,.10);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.statusBar .sbTag{display:inline-block;margin-right:10px;color:#93c5fd;font-weight:700;}

@media (max-width: 980px){
  .daily-apps{ display:none; }
  .workflow-switcher-wrap{ display:flex; }
  .brand{ margin-right: 10px; }
}
