/* DIARY ONE — Connected App Styling (Sprint 1) */
[hidden], .hide { display: none !important; }

.diary-shell { display: flex; min-height: 100vh; background: var(--bg); color: var(--text); }
.side-nav {
  width: 260px; min-width: 260px; background: #0b1221;
  border-right: 1px solid #1f2b3d; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.nav-container { flex: 1; overflow-y: auto; padding-bottom: 20px; scrollbar-width: thin; scrollbar-color: #24354c transparent; }
.nav-btn {
  position: relative; width: 100%; border: 0; background: transparent; text-align: left;
  color: #92a3bb; display: flex; align-items: center; gap: 11px; padding: 10px 14px;
  border-radius: 10px; font-weight: 560; font-size: 13px; transition: background .15s, color .15s;
}
.nav-btn:hover { background: #152236; color: #f2f7ff; }
.nav-btn.active { background: linear-gradient(90deg, #18333e, #132433); color: var(--accent); font-weight: 650; }
.nav-btn.active:before { content: ""; width: 3px; height: 22px; background: var(--accent); position: absolute; left: 0; border-radius: 0 4px 4px 0; }
.nav-btn svg.icon { width: 17px; height: 17px; }

.pill { font-size: 10px; padding: 2px 7px; border-radius: 6px; margin-left: auto; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.pill.core { background: #163c35; color: #6be3c5; border: 1px solid #286457; }
.pill.warn { background: #4a2818; color: #ffab70; border: 1px solid #7c4021; }
.pill.roadmap { background: #1c2738; color: #7f95b0; border: 1px solid #2d3e56; font-size: 9px; }

/* Login */
.login-surface { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 75% 25%, #18444e, transparent 50%), #090e19; padding: 20px; }
.login-panel { max-width: 440px; width: 100%; padding: 40px; background: #111c2e; border: 1px solid #2c4257; border-radius: 24px; box-shadow: 0 28px 90px rgba(0,0,0,.6); text-align: center; }
.login-panel .mark { margin: 0 auto 16px; }
.login-panel h1 { letter-spacing: 3px; margin: 0 0 6px; font-size: 24px; }
.login-panel p { color: #8e9fb5; margin: 0 0 24px; font-size: 13px; }
.login-panel form { display: grid; gap: 13px; text-align: left; }
.login-panel label { font-size: 12px; font-weight: 600; color: #a9bccf; }
.login-panel input { border-radius: 10px; background: #0a1322; border: 1px solid #2b3e54; padding: 12px 14px; color: #fff; width: 100%; }
.login-panel button { margin-top: 8px; width: 100%; padding: 13px; }
.error { color: #ff858d !important; font-size: 12px; margin: 10px 0 0; }

/* Layout & Topbar */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 68px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #1c283a; padding: 0 32px; background: #0b1220; gap: 15px; position: sticky; top: 0; z-index: 30;
}
.breadcrumbs { font-size: 12px; color: #8fa0b5; display: flex; align-items: center; gap: 8px; }
.breadcrumbs strong { color: #eaf3ff; font-weight: 650; }
.top-ws-name { color: #7fe6cf; font-weight: 700; background: #132b31; padding: 2px 8px; border-radius: 6px; border: 1px solid #254a4f; }
.top-actions { display: flex; align-items: center; gap: 10px; }
main#screen { padding: 30px 34px 60px; max-width: 1650px; width: 100%; margin: 0 auto; }

/* Subnav Tabs */
.subnav-tabs { display: flex; gap: 8px; border-bottom: 1px solid #23344a; padding-bottom: 12px; margin-bottom: 24px; }
.tab-btn {
  background: transparent; border: 1px solid transparent; color: #8e9fb5;
  padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; transition: all .15s;
}
.tab-btn:hover { background: #152438; color: #fff; }
.tab-btn.active { background: #19343f; border-color: #2e625a; color: var(--accent); }

/* KPI Grid */
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: #121d30; border: 1px solid #23354b; border-radius: 17px;
  padding: 20px 22px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
}
.kpi-card .kpi-head { display: flex; justify-content: space-between; align-items: center; color: #8e9eb5; font-size: 12px; font-weight: 600; }
.kpi-card .kpi-num { font-size: 32px; font-weight: 800; line-height: 1.2; margin: 12px 0 4px; letter-spacing: -1px; }
.kpi-card .kpi-sub { font-size: 11px; color: #75879f; }
.kpi-card.urgent-unread .kpi-num { color: #51e7c5; }
.kpi-card.urgent-overdue .kpi-num { color: #ff858d; }
.kpi-card.urgent-approval .kpi-num { color: #ffbe79; }
.kpi-card.pipeline-card .kpi-num { color: #86aaff; }

/* Empty States */
.empty-banner {
  border: 1px solid #264a43; background: linear-gradient(130deg, #11282a, #132034);
  padding: 16px 20px; border-radius: 14px; margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.empty-banner-content strong { display: block; font-size: 13px; color: #72efcb; margin-bottom: 3px; }
.empty-banner-content p { margin: 0; font-size: 12px; color: #9ab4c7; }

/* 2 Panels & Layouts */
.split-panels { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-top: 20px; }
.card-panel { background: #121d30; border: 1px solid #23354b; border-radius: 17px; padding: 22px; min-width: 0; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 15px; font-weight: 750; letter-spacing: -.2px; }

/* Urgent Lists */
.urgent-list { display: flex; flex-direction: column; gap: 10px; }
.urgent-item {
  border: 1px solid #283a52; background: #162438; border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.urgent-item b { display: block; font-size: 13px; margin-bottom: 4px; }
.urgent-item small { color: #8ca0b8; font-size: 11px; }

/* Activity Feed */
.activity-feed { display: flex; flex-direction: column; gap: 12px; }
.activity-item { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid #1c2b3e; }
.activity-item:last-child { border-bottom: 0; padding-bottom: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; box-shadow: 0 0 8px var(--accent); }
.activity-text strong { font-size: 12px; color: #e6efff; }
.activity-text p { margin: 3px 0 0; color: #8e9fb5; font-size: 11px; }
.activity-text time { display: block; font-size: 10px; color: #62758e; margin-top: 4px; }

/* Tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.crm-table { width: 100%; border-collapse: collapse; text-align: left; }
.crm-table th, .crm-table td { padding: 13px 14px; border-bottom: 1px solid #223247; font-size: 13px; }
.crm-table th { color: #8697ae; font-weight: 600; font-size: 12px; background: #101a2b; position: sticky; top: 0; }
.crm-table tr:hover td { background: #152236; }
.crm-table .tag { font-size: 10px; padding: 3px 8px; border-radius: 6px; }

/* 3-Column Unified Inbox */
.inbox-3col { display: grid; grid-template-columns: 290px minmax(360px, 1fr) 280px; gap: 16px; min-height: 600px; }
.inbox-sidebar { background: #101a2c; border: 1px solid #22344a; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.inbox-filter-bar { padding: 14px; border-bottom: 1px solid #22344a; display: flex; flex-direction: column; gap: 10px; }
.chip-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip-btn {
  background: #172437; border: 1px solid #2b3d54; color: #8e9fb5; font-size: 11px;
  padding: 5px 9px; border-radius: 7px; cursor: pointer; transition: all .15s;
}
.chip-btn.active { background: #19383e; border-color: #377169; color: var(--accent); font-weight: 700; }
.inbox-list { flex: 1; overflow-y: auto; }
.inbox-entry {
  width: 100%; display: block; text-align: left; background: transparent; border: 0;
  border-bottom: 1px solid #1c2b3e; padding: 13px 15px; cursor: pointer; transition: background .15s;
}
.inbox-entry:hover { background: #162438; }
.inbox-entry.active { background: #18333e; border-left: 3px solid var(--accent); }
.inbox-entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.inbox-entry-head strong { font-size: 13px; color: #eaf2ff; }
.inbox-entry-head time { font-size: 10px; color: #72849c; }
.inbox-entry-preview { font-size: 11px; color: #889bb2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-badge-dot { width: 7px; height: 7px; border-radius: 50%; background: #51e7c5; display: inline-block; margin-right: 6px; box-shadow: 0 0 6px #51e7c5; }

/* Chat Thread */
.inbox-chat { background: #121d30; border: 1px solid #22344a; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { padding: 14px 20px; border-bottom: 1px solid #22344a; display: flex; justify-content: space-between; align-items: center; background: #101b2c; }
.chat-head h3 { margin: 0; font-size: 14px; }
.chat-head small { color: #8697ae; font-size: 11px; display: block; margin-top: 3px; }
.chat-stream { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 80%; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; word-break: break-word; }
.chat-msg.inbound { background: #1a2a40; border: 1px solid #2b3f58; align-self: flex-start; border-bottom-left-radius: 3px; }
.chat-msg.outbound { background: #1a4244; border: 1px solid #2c6f66; align-self: flex-end; border-bottom-right-radius: 3px; }
.chat-notice { padding: 12px 16px; border-top: 1px solid #22344a; background: #0e1726; color: #8798ad; font-size: 11px; text-align: center; }

/* Customer 360 / Action Panel */
.customer-360-panel { background: #101a2c; border: 1px solid #22344a; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.customer-360-panel h3 { margin: 0 0 4px; font-size: 14px; }
.context-block { background: #152236; border: 1px solid #263850; border-radius: 12px; padding: 12px; font-size: 12px; }
.context-block label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #778ca6; margin-bottom: 4px; font-weight: 700; }
.context-block strong { font-size: 13px; color: #eaf3ff; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 7, 16, 0.78); backdrop-filter: blur(6px);
  z-index: 100; display: grid; place-items: center; padding: 16px;
}
.modal-box {
  background: #121e32; border: 1px solid #2d435b; border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0,0,0,.6); width: min(520px, 100%); padding: 26px; position: relative;
}
.modal-box h3 { margin: 0 0 6px; font-size: 18px; font-weight: 750; }
.modal-box p { font-size: 12px; color: #8e9fb5; margin: 0 0 20px; line-height: 1.6; }
.modal-form { display: grid; gap: 12px; }
.modal-form label { font-size: 11px; font-weight: 700; color: #9cb1c9; }
.modal-form input, .modal-form select, .modal-form textarea {
  background: #0d1726; border: 1px solid #2c4057; border-radius: 9px; padding: 10px 12px; color: #fff; width: 100%;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.close-btn { position: absolute; top: 18px; right: 18px; background: transparent; border: 0; color: #8295ac; cursor: pointer; padding: 4px; }

/* Toast */
#toast {
  position: fixed; right: 24px; bottom: 24px; color: #d6fff4; background: #133c3a;
  border: 1px solid #2e7a6f; padding: 12px 18px; border-radius: 11px; z-index: 110;
  box-shadow: 0 16px 40px rgba(0,0,0,.5); font-size: 12px; font-weight: 600;
  opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.on { opacity: 1; transform: translateY(0); }

/* Filter Banner */
.filter-banner {
  background: #172439; border: 1px solid #2c4463; border-radius: 12px;
  padding: 10px 16px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between;
}
.filter-banner span { font-size: 13px; color: #8eb1d4; font-weight: 600; }

/* Task Comments & Details */
.task-card { cursor: pointer; transition: transform .15s, border-color .15s; }
.task-card:hover { border-color: #3f6087; transform: translateY(-2px); }
.comments-thread { display: flex; flex-direction: column; gap: 10px; max-height: 240px; overflow-y: auto; margin: 12px 0; }
.comment-bubble { background: #0c1524; border: 1px solid #1f2f45; border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.comment-bubble .comment-author { font-weight: 700; color: #6be3c5; margin-bottom: 4px; font-size: 11px; }
.comment-bubble .comment-time { color: #586d87; font-size: 10px; margin-left: 8px; }

/* Mission Control Grid */
.missions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; margin-top: 16px; }
.mission-card {
  background: #121e33; border: 1px solid #243750; border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
}
.mission-card h3 { margin: 0; font-size: 15px; color: #eaf2ff; }
.mission-card p { margin: 0; font-size: 12px; color: #8e9fb5; line-height: 1.5; }
.mission-meta { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: #6e84a0; background: #0c1424; padding: 10px; border-radius: 10px; }

/* Org Dashboard */
.org-workspaces-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; margin-top: 20px; }
.org-ws-card {
  background: #111d31; border: 1px solid #23364f; border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.org-ws-head { display: flex; justify-content: space-between; align-items: center; }
.org-ws-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: #0c1524; padding: 12px; border-radius: 12px; font-size: 12px; }
.org-ws-metrics div strong { display: block; font-size: 16px; color: #fff; margin-top: 2px; }

/* Responsive Media Queries */
@media(max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-panels { grid-template-columns: 1fr; }
  .inbox-3col { grid-template-columns: 260px 1fr; }
  .customer-360-panel { grid-column: 1 / -1; }
}

@media(max-width: 820px) {
  .side-nav {
    position: fixed; left: -270px; top: 0; height: 100vh; z-index: 90;
    transition: left .25s ease; box-shadow: 10px 0 30px rgba(0,0,0,.5);
  }
  .diary-shell.show-menu .side-nav { left: 0; }
  .topbar { padding: 0 16px; }
  .mobilemenu { display: grid; }
  main#screen { padding: 20px 16px 40px; }
  .inbox-3col { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* Installed app (iPhone notch / home bar): keep content out of the status bar and home indicator. */
.topbar { height: calc(68px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
.side-nav { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
#screen { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
#toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
