html {
  box-sizing: border-box;
}

body,
div,
span,
main,
header,
aside,
nav,
section,
article,
form,
input,
select,
textarea,
button,
table,
thead,
tbody,
tr,
th,
td,
img,
p,
h1,
h2,
h3,
h4,
h5,
h6,
a,
small,
label {
  box-sizing: border-box;
}

body {
  background-color: #f1f5f9;
  color: #0f172a;
  height: 100vh;
  display: flex;
  overflow: hidden;
  position: relative;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button,
input,
select,
textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Watermark Overlay */
.app-watermark-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: url('../../watermark.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 440px auto;
  opacity: 0.16;
  pointer-events: none;
  z-index: 20;
}

/* Buttons */
button {
  cursor: pointer;
  border: 0;
  min-height: 38px;
  border-radius: 8px;
  font-weight: 600;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: #fee2e2;
  color: #ef4444;
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-purple {
  background: #8b5cf6;
  color: #ffffff;
}

.btn-purple:hover {
  opacity: 0.9;
}

/* Form Controls */
input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  background: #ffffff;
  color: #0f172a;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #0284c7;
}

/* Pull Down Refresh Indicator */
.pull-refresh-indicator {
  box-sizing: border-box;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #0284c7;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.10);
  z-index: 80;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
  border-bottom: 2px solid #0284c7;
  gap: 8px;
}

/* In-App Message Toast Notification */
.in-app-toast-box {
  box-sizing: border-box;
  position: fixed;
  top: 16px;
  left: 50%;
  width: 92%;
  max-width: 420px;
  transform: translateX(-50%) translateY(-150%);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.in-app-toast-box.show {
  transform: translateX(-50%) translateY(0);
}

/* Navigation Badges */
.nav-badge-counter {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.20);
}

.mobile-badge-counter {
  box-sizing: border-box;
  position: absolute;
  top: 3px;
  right: 8px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.20);
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #0f172a;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.auth-card {
  box-sizing: border-box;
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: 20px;
  padding: 32px 28px 22px 28px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.10);
  text-align: center;
  margin: auto;
  position: relative;
}

.auth-branding-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 6px 16px;
  border-radius: 24px;
  margin-bottom: 12px;
  border: 1px solid #bae6fd;
}

.auth-sub {
  font-size: 0.86rem;
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.4;
}

.auth-error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: none;
  text-align: left;
}

.compliance-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 0.8rem;
  color: #0284c7;
  margin-top: 18px;
}

.compliance-links a {
  color: #0284c7;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}

.auth-footer {
  margin-top: 16px;
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
  font-size: 0.76rem;
  color: #64748b;
  user-select: none;
}

.secret-admin-trigger {
  cursor: pointer;
  color: inherit;
  padding: 4px 6px;
  border-radius: 4px;
}

.secret-admin-trigger:hover {
  background: #f1f5f9;
}

/* Desktop Sidebar */
.desktop-sidebar {
  box-sizing: border-box;
  width: 260px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  border-right: 1px solid #1e293b;
}

.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-logo-slot {
  box-sizing: border-box;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
  flex-shrink: 0;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  position: relative;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-item.active {
  background: #0284c7;
  color: #ffffff;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #090e17;
}

/* Main Wrapper & Topbar */
.desktop-main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.desktop-topbar {
  box-sizing: border-box;
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 30;
}

.main-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  z-index: 10;
  position: relative;
}

.view-panel {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
}

.view-panel.active {
  display: block;
}

/* Cards & Grid Layouts */
.card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  position: relative;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.desktop-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.desktop-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Filter Bars */
.task-scope-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.task-scope-bar::-webkit-scrollbar {
  display: none;
}

.scope-pill {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.scope-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.scope-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.task-buckets-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.task-buckets-bar::-webkit-scrollbar {
  display: none;
}

.bucket-pill {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.bucket-pill:hover {
  background: #f8fafc;
  color: #0f172a;
}

.bucket-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.bucket-badge {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #334155;
}

.bucket-pill.active .bucket-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* 3-Dots Dropdown */
.menu-container {
  position: relative;
}

.three-dots-btn {
  box-sizing: border-box;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
}

.three-dots-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.dropdown-menu {
  position: absolute;
  top: 38px;
  right: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.10);
  z-index: 70;
  min-width: 200px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-bottom: 1px solid #f8fafc;
}

.dropdown-item:hover {
  background: #f8fafc;
}

.dropdown-item.danger {
  color: #ef4444;
}

.dropdown-item.danger:hover {
  background: #fee2e2;
}

/* Status & Priority Badges */
.status-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-unattended {
  background: #fef3c7;
  color: #b45309;
}

.status-working {
  background: #e0f2fe;
  color: #0369a1;
}

.status-issues {
  background: #fee2e2;
  color: #b91c1c;
}

.status-completed {
  background: #dcfce7;
  color: #15803d;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #0f172a;
  margin-top: 8px;
  cursor: pointer;
}

.attachment-pill:hover {
  background: #e2e8f0;
  border-color: #0284c7;
}

/* Chat */
.chat-subtabs-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.chat-subtab-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #64748b;
}

.chat-subtab-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.laptop-chat-container {
  box-sizing: border-box;
  display: flex;
  height: calc(100vh - 190px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.laptop-chat-list {
  box-sizing: border-box;
  width: 320px;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  background: #fafafa;
}

.laptop-chat-active-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.chat-user-row {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-user-row:hover {
  background: #f1f5f9;
}

.chat-user-row.selected {
  background: #e0f2fe;
  border-left: 4px solid #0284c7;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  word-break: break-word;
  position: relative;
}

.msg-self {
  align-self: flex-end;
  background: #dcf8c6;
}

.msg-peer {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.msg-meta-row {
  font-size: 0.68rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

.msg-delete-btn {
  background: transparent;
  border: 0;
  padding: 0 4px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #ef4444;
  opacity: 0.7;
}

.msg-delete-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.chat-input-row {
  padding: 12px 18px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
}

/* Scratchpad Drafts */
.draft-container {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  padding: 22px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.draft-textarea {
  box-sizing: border-box;
  width: 100%;
  height: 420px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 18px;
  font-size: 1rem;
  line-height: 1.8;
  resize: vertical;
  background: #fafafa;
  font-family: inherit;
}

/* Storage & Quota */
.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 10px;
}

.usage-table th,
.usage-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.usage-table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.storage-meter {
  background: #e2e8f0;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 8px 0;
}

.storage-meter-fill {
  background: #0284c7;
  height: 100%;
  transition: width 0.3s;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.80);
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-backdrop.active {
  display: flex;
}

.modal-box {
  background: #ffffff;
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 32px);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: auto;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.10);
}

.modal-box > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  max-height: calc(100vh - 96px);
  overflow: hidden;
}

.modal-header {
  flex: 0 0 auto;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  flex: 0 0 auto;
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafafa;
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Theme Picker */
.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.theme-option-box {
  box-sizing: border-box;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
}

.theme-option-box.selected {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #ffffff inset;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
}

.upload-dropzone:hover {
  border-color: #0284c7;
  background: #f0f9ff;
}

/* Small Screens */
@media (max-width: 647px) {
  .app-watermark-overlay {
    background-size: 68vw auto;
  }
}
